blob: d8aaeb4d7fbf95d3aff2ee91b6082119df48298d (
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
53
54
|
;;; test-telega-config.el --- Tests for Telegram (telega) module wiring -*- lexical-binding: t; -*-
;;; Commentary:
;; Lightweight asserts that the module loads, exposes the launcher,
;; sets the docker preference, and registers the C-; G keybinding.
;; The bulk of telega.el's behaviour is owned upstream; the tests
;; here only cover what this config wires.
;;; Code:
(require 'ert)
(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
(require 'telega-config)
(ert-deftest test-telega-config-loads-cleanly ()
"Normal: module loads without errors and `provide's its feature."
(should (featurep 'telega-config)))
(ert-deftest test-telega-config-launcher-binding-is-telega ()
"Normal: =C-; T= invokes the launcher wrapper, which routes to
`telega' when installed or signals a helpful user-error otherwise.
Was =C-; G= when `T' was contested between org-table and transcription
menus; both have moved (org-table flattened under `C-; O',
transcription cleared to M-x), so the natural mnemonic is free."
(should (eq (keymap-lookup cj/custom-keymap "T") #'cj/telega)))
(ert-deftest test-telega-config-launcher-without-package-signals-user-error ()
"Error: with telega absent, the launcher signals a `user-error' that
mentions the recovery path instead of falling through to the autoload
stub's cryptic load-file failure."
(cl-letf (((symbol-function 'featurep)
(lambda (sym &optional _sub)
(and (not (eq sym 'telega)) t)))
((symbol-function 'locate-library)
(lambda (lib &rest _) (unless (equal lib "telega") t))))
(let* ((err (should-error (cj/telega) :type 'user-error))
(msg (error-message-string err)))
(should (string-match-p "telega not installed" msg))
(should (string-match-p "setup-telega\\.sh\\|package-install" msg)))))
(ert-deftest test-telega-config-launcher-with-package-calls-telega ()
"Normal: with telega loadable, the launcher delegates to `telega'."
(let (called)
(cl-letf (((symbol-function 'featurep)
(lambda (sym &optional _sub) (eq sym 'telega)))
((symbol-function 'telega)
(lambda (&rest _) (setq called t))))
(cj/telega))
(should called)))
(provide 'test-telega-config)
;;; test-telega-config.el ends here
|