blob: 43cfe9452222e523ef08bee39f1cc9d4d2ae009d (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
;;; test-prog-webdev--format-wiring.el --- Verify the TS/JS formatter is wired -*- lexical-binding: t; -*-
;;; Commentary:
;; Webdev's binding is installed via `local-set-key' inside the
;; `cj/webdev-keybindings' hook, fired from typescript-ts-mode,
;; tsx-ts-mode, js-ts-mode, and web-mode. The format command itself
;; (`cj/webdev-format-buffer') is defined in prog-webdev.el and shells
;; out to the `prettier' binary.
;;
;; Three checks:
;; 1. `cj/webdev-format-buffer' is fboundp.
;; 2. The hook installs C-; f → `cj/webdev-format-buffer' in the
;; buffer-local map.
;; 3. The `prettier' executable is on PATH.
;;; Code:
(require 'ert)
(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
(add-to-list 'load-path (expand-file-name "tests" user-emacs-directory))
(require 'testutil-format-wiring)
(format-test--ensure-packages-init)
(require 'prog-webdev)
(ert-deftest test-prog-webdev-format-package-loaded ()
"Normal: `prog-webdev' is in `features' after load.
The webdev formatter is a custom function defined in prog-webdev
itself, so this asserts the module loaded rather than a separate
formatter package (there isn't one — `cj/webdev-format-buffer'
shells out to the `prettier' CLI directly)."
(should (featurep 'prog-webdev)))
(ert-deftest test-prog-webdev-format-command-fboundp ()
"Normal: `cj/webdev-format-buffer' is fboundp from prog-webdev."
(should (fboundp 'cj/webdev-format-buffer)))
(ert-deftest test-prog-webdev-format-binding-resolves ()
"Normal: `cj/webdev-keybindings' installs C-; f → `cj/webdev-format-buffer'."
(with-temp-buffer
(cj/webdev-keybindings)
(should (eq 'cj/webdev-format-buffer
(local-key-binding (kbd "C-; f"))))))
(ert-deftest test-prog-webdev-format-executable-on-path ()
"Boundary: `prettier' is on PATH (skipped if not installed)."
(format-test--skip-unless-executable "prettier")
(should (executable-find "prettier")))
(provide 'test-prog-webdev--format-wiring)
;;; test-prog-webdev--format-wiring.el ends here
|