aboutsummaryrefslogtreecommitdiff
path: root/tests/test-ui-navigation--split-dashboard.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-16 14:56:59 -0500
committerCraig Jennings <c@cjennings.net>2026-06-16 14:56:59 -0500
commit430fe98b1619b1ea4ba67b56679e0d10e7ab3c6c (patch)
tree93cd98c19270a7819d1992a2caf1eaf37aadb975 /tests/test-ui-navigation--split-dashboard.el
parent9b41fb33ea92420e372bc702004a04825555f16b (diff)
downloaddotemacs-430fe98b1619b1ea4ba67b56679e0d10e7ab3c6c.tar.gz
dotemacs-430fe98b1619b1ea4ba67b56679e0d10e7ab3c6c.zip
feat(ui-navigation): split from the dashboard opens scratch, not the dashboard
C-x 2 / C-x 3 already show the dashboard in the new window while point stays put. The one dead spot was splitting from the dashboard itself, which put the dashboard in both panes. Now the new window shows *scratch* when the current buffer is the dashboard, and the dashboard everywhere else. I pulled the choice into a pure predicate (cj/--split-from-dashboard-p) and a companion helper, both tested.
Diffstat (limited to 'tests/test-ui-navigation--split-dashboard.el')
-rw-r--r--tests/test-ui-navigation--split-dashboard.el21
1 files changed, 21 insertions, 0 deletions
diff --git a/tests/test-ui-navigation--split-dashboard.el b/tests/test-ui-navigation--split-dashboard.el
index b815a4c59..407335f80 100644
--- a/tests/test-ui-navigation--split-dashboard.el
+++ b/tests/test-ui-navigation--split-dashboard.el
@@ -54,6 +54,27 @@
(should (eq (car captured) #'split-window-right))
(should (eq (cadr captured) 'dashboard))))
+(ert-deftest test-ui-navigation-split-from-dashboard-p ()
+ "Normal/Boundary: only the dashboard buffer routes the companion to *scratch*."
+ (should (cj/--split-from-dashboard-p "*dashboard*"))
+ (should-not (cj/--split-from-dashboard-p "todo.org"))
+ (should-not (cj/--split-from-dashboard-p "*scratch*")))
+
+(ert-deftest test-ui-navigation-split-companion-scratch-from-dashboard ()
+ "Normal: splitting from the dashboard yields the *scratch* buffer, not the
+dashboard again."
+ (cl-letf (((symbol-function 'cj/--split-from-dashboard-p) (lambda (_) t))
+ ((symbol-function 'get-scratch-buffer-create) (lambda () 'scratch))
+ ((symbol-function 'cj/--dashboard-buffer) (lambda () 'dashboard)))
+ (should (eq (cj/--split-companion-buffer) 'scratch))))
+
+(ert-deftest test-ui-navigation-split-companion-dashboard-otherwise ()
+ "Normal: splitting from any other buffer yields the dashboard."
+ (cl-letf (((symbol-function 'cj/--split-from-dashboard-p) (lambda (_) nil))
+ ((symbol-function 'get-scratch-buffer-create) (lambda () 'scratch))
+ ((symbol-function 'cj/--dashboard-buffer) (lambda () 'dashboard)))
+ (should (eq (cj/--split-companion-buffer) 'dashboard))))
+
(ert-deftest test-ui-navigation-dashboard-buffer-returns-existing ()
"Boundary: cj/--dashboard-buffer returns an existing *dashboard* without opening."
(let ((db (get-buffer-create "*dashboard*"))