aboutsummaryrefslogtreecommitdiff
path: root/tests/test-system-commands-keymap.el
blob: 82be1d8dead7ab54c8146eb180dac9033e97ce5b (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
;;; test-system-commands-keymap.el --- Tests for system command keymap -*- lexical-binding: t; -*-

;;; Commentary:

;; C-; ! is bound directly to the completing-read menu.  The per-command leaf
;; keys (s/r/e/l/L/E/S) were removed to reclaim the key real-estate; every
;; command stays reachable through the menu (see the menu-dispatch test).

;;; Code:

(require 'ert)

(defvar cj/custom-keymap (make-sparse-keymap)
  "Stub custom keymap for system-commands tests.")

(require 'system-commands)

(ert-deftest test-system-commands-keymap-normal-menu-bound-directly ()
  "Normal: C-; ! is the completing-read menu command, not a prefix keymap."
  (let ((binding (keymap-lookup cj/custom-keymap "!")))
    (should (eq binding 'cj/system-command-menu))
    (should (commandp binding))))

(ert-deftest test-system-commands-keymap-normal-leaf-subkeys-removed ()
  "Normal: no subkeys hang off C-; !, and the commands remain defined."
  ;; "!" is now a command, not a prefix, so there is no submap to walk into.
  (should-not (keymapp (keymap-lookup cj/custom-keymap "!")))
  ;; The commands themselves stay defined and reachable via the menu.
  (dolist (cmd '(cj/system-cmd-logout cj/system-cmd-reboot cj/system-cmd-shutdown
                 cj/system-cmd-suspend cj/system-cmd-lock cj/system-cmd-exit-emacs
                 cj/system-cmd-restart-emacs))
    (should (fboundp cmd))))

(provide 'test-system-commands-keymap)
;;; test-system-commands-keymap.el ends here