aboutsummaryrefslogtreecommitdiff
path: root/tests/test-prog-general--install-treesit-grammars.el
blob: 62bf3920598076c6b0c0c5a206e980b82300e82e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
;;; test-prog-general--install-treesit-grammars.el --- Grammar bootstrap command -*- lexical-binding: t; -*-

;;; Commentary:
;; `treesit-auto-install' is set to `prompt' so opening a file never silently
;; downloads and builds a grammar.  `cj/install-treesit-grammars' is the
;; explicit fresh-machine bootstrap: it loads treesit-auto and installs every
;; grammar in one deliberate command.

;;; Code:

(require 'ert)
(require 'cl-lib)

(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
(require 'prog-general)

;; Satisfy the command's (require 'treesit-auto) without the real package,
;; which isn't available in batch runs.
(provide 'treesit-auto)

(ert-deftest test-prog-general-install-treesit-grammars-is-a-command ()
  "Normal: the bootstrap entry point exists and is interactive."
  (should (commandp 'cj/install-treesit-grammars)))

(ert-deftest test-prog-general-install-treesit-grammars-installs-all ()
  "Normal: the command delegates to treesit-auto-install-all."
  (let ((called 0))
    (cl-letf (((symbol-function 'treesit-auto-install-all)
               (lambda (&rest _) (setq called (1+ called)))))
      (cj/install-treesit-grammars)
      (should (= called 1)))))

(provide 'test-prog-general--install-treesit-grammars)
;;; test-prog-general--install-treesit-grammars.el ends here