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
commitd845b34bb44a61e673cb715dbe5309d40f52c5fe (patch)
tree1aa3057d0a5dfc0809ccc2b0c8ec41552dd70100 /tests/test-ui-navigation--split-dashboard.el
parentd5d861cf3b7a53ac4d9d5d5a4f0fad55eee16137 (diff)
downloaddotemacs-d845b34bb44a61e673cb715dbe5309d40f52c5fe.tar.gz
dotemacs-d845b34bb44a61e673cb715dbe5309d40f52c5fe.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 b815a4c5..407335f8 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*"))