aboutsummaryrefslogtreecommitdiff
path: root/archive/tests/test-telega-config.el
diff options
context:
space:
mode:
Diffstat (limited to 'archive/tests/test-telega-config.el')
-rw-r--r--archive/tests/test-telega-config.el58
1 files changed, 58 insertions, 0 deletions
diff --git a/archive/tests/test-telega-config.el b/archive/tests/test-telega-config.el
new file mode 100644
index 00000000..54a601c9
--- /dev/null
+++ b/archive/tests/test-telega-config.el
@@ -0,0 +1,58 @@
+;;; 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)))
+ ;; The pinned image is a local build; treat it as present so
+ ;; this test stays about delegation, not the image check.
+ ((symbol-function 'cj/--telega-docker-image-present-p)
+ (lambda (_) t))
+ ((symbol-function 'telega)
+ (lambda (&rest _) (setq called t))))
+ (cj/telega))
+ (should called)))
+
+(provide 'test-telega-config)
+;;; test-telega-config.el ends here