aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-20 12:28:06 -0400
committerCraig Jennings <c@cjennings.net>2026-06-20 12:28:06 -0400
commit274a92e910b17f355f76180d1071c6400de64251 (patch)
treed9852505e053aaa0d85d8602e67e603ac21cd4df /tests
parent098d3a0dc2fbeeb296433be68f980708e1670dc3 (diff)
downloaddotemacs-274a92e910b17f355f76180d1071c6400de64251.tar.gz
dotemacs-274a92e910b17f355f76180d1071c6400de64251.zip
refactor(modeline): extract the clickable-segment keymap builder
The buffer-name, vc, and major-mode segments each hand-rolled the same make-sparse-keymap + define-key [mode-line mouse-1/3] construction. Extract cj/--modeline-click-map (mouse-1 &optional mouse-3); the three segments call it. Adds coverage for the one- and two-button cases.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-modeline-config--click-map.el29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test-modeline-config--click-map.el b/tests/test-modeline-config--click-map.el
new file mode 100644
index 000000000..6c5ba4c7e
--- /dev/null
+++ b/tests/test-modeline-config--click-map.el
@@ -0,0 +1,29 @@
+;;; test-modeline-config--click-map.el --- Tests for cj/--modeline-click-map -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; cj/--modeline-click-map is the shared mode-line `local-map' builder extracted
+;; from three clickable segments (buffer-name, vc, major-mode) that each spelled
+;; out the same make-sparse-keymap + define-key dance.
+
+;;; Code:
+
+(require 'ert)
+
+(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
+(require 'modeline-config)
+
+(ert-deftest test-modeline-click-map-binds-mouse-1-and-3 ()
+ "Normal: with both commands, mouse-1 and mouse-3 are bound."
+ (let ((map (cj/--modeline-click-map 'vc-diff 'vc-root-diff)))
+ (should (keymapp map))
+ (should (eq (lookup-key map [mode-line mouse-1]) 'vc-diff))
+ (should (eq (lookup-key map [mode-line mouse-3]) 'vc-root-diff))))
+
+(ert-deftest test-modeline-click-map-mouse-1-only ()
+ "Boundary: with no MOUSE-3, only mouse-1 is bound."
+ (let ((map (cj/--modeline-click-map 'describe-mode)))
+ (should (eq (lookup-key map [mode-line mouse-1]) 'describe-mode))
+ (should (null (lookup-key map [mode-line mouse-3])))))
+
+(provide 'test-modeline-config--click-map)
+;;; test-modeline-config--click-map.el ends here