aboutsummaryrefslogtreecommitdiff
path: root/tests
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
commit4bfdc0a1f56d877c23cec895bdc108e0f196e18c (patch)
treef01de5875f30d2a259b04269ac3611a0ab1127df /tests
parent58a38dcba409c604a2c11fdc578bfa298926be56 (diff)
downloaddotemacs-4bfdc0a1f56d877c23cec895bdc108e0f196e18c.tar.gz
dotemacs-4bfdc0a1f56d877c23cec895bdc108e0f196e18c.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')
-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*"))