diff options
| author | Szymon Szukalski <szymon@szymonszukalski.com> | 2026-04-10 17:59:11 +1000 |
|---|---|---|
| committer | Szymon Szukalski <szymon@szymonszukalski.com> | 2026-04-10 17:59:11 +1000 |
| commit | 4b2d5710d6d4439281333a5be11fc7bcd9d3359e (patch) | |
| tree | a995a1372d67828edea0d6225a694c3868714ae5 /tests/ss-capture-tests.el | |
| parent | 63797ae271dabdeb2e3bd54e103066e7c9ea4b3c (diff) | |
blank slate
Diffstat (limited to 'tests/ss-capture-tests.el')
| -rw-r--r-- | tests/ss-capture-tests.el | 176 |
1 files changed, 0 insertions, 176 deletions
diff --git a/tests/ss-capture-tests.el b/tests/ss-capture-tests.el deleted file mode 100644 index 006c90d..0000000 --- a/tests/ss-capture-tests.el +++ /dev/null @@ -1,176 +0,0 @@ -;;; ss-capture-tests.el --- Tests for ss-capture -*- lexical-binding: t; -*- - -;;; Commentary: - -;; Focused ERT coverage for journal capture structure helpers. - -;;; Code: - -(add-to-list 'load-path (expand-file-name "../lisp" (file-name-directory load-file-name))) - -(require 'cl-lib) -(require 'ert) -(require 'ss-capture) -(require 'ss-org) - -(ert-deftest ss-jump-back-restores-previous-location-and-enables-forward () - (let ((ss-navigation-back-stack nil) - (ss-navigation-forward-stack nil) - (buffer-a (generate-new-buffer " *ss-nav-a*")) - (buffer-b (generate-new-buffer " *ss-nav-b*"))) - (unwind-protect - (save-window-excursion - (with-current-buffer buffer-a - (insert "alpha") - (goto-char 3)) - (with-current-buffer buffer-b - (insert "bravo") - (goto-char 5)) - (switch-to-buffer buffer-a) - (ss-navigation-push-current-location) - (switch-to-buffer buffer-b) - (should (ss-jump-back)) - (should (eq (current-buffer) buffer-a)) - (should (= (point) 3)) - (should (ss-jump-forward)) - (should (eq (current-buffer) buffer-b)) - (should (= (point) 5))) - (kill-buffer buffer-a) - (kill-buffer buffer-b)))) - -(ert-deftest ss-navigation-push-current-location-clears-forward-after-back () - (let ((ss-navigation-back-stack nil) - (ss-navigation-forward-stack nil) - (buffer-a (generate-new-buffer " *ss-nav-a*")) - (buffer-b (generate-new-buffer " *ss-nav-b*"))) - (unwind-protect - (save-window-excursion - (with-current-buffer buffer-a - (insert "alpha") - (goto-char 2)) - (with-current-buffer buffer-b - (insert "bravo") - (goto-char 4)) - (switch-to-buffer buffer-a) - (ss-navigation-push-current-location) - (switch-to-buffer buffer-b) - (should (ss-jump-back)) - (should ss-navigation-forward-stack) - (ss-navigation-push-current-location) - (should-not ss-navigation-forward-stack)) - (kill-buffer buffer-a) - (kill-buffer buffer-b)))) - -(ert-deftest ss-navigation-record-jump-skips-noop-movements () - (let ((ss-navigation-back-stack nil) - (ss-navigation-forward-stack nil)) - (with-temp-buffer - (switch-to-buffer (current-buffer)) - (insert "alpha") - (goto-char 2) - (ss-navigation--record-jump (lambda () nil)) - (should-not ss-navigation-back-stack) - (should-not ss-navigation-forward-stack)))) - -(ert-deftest ss-journal-ensure-day-sections-adds-all-standard-sections () - (with-temp-buffer - (org-mode) - (insert "#+title: Journal\n" - "#+startup: overview\n\n" - "* 2026\n" - "** 2026-04-08 Wednesday\n" - "*** Tasks\n" - "**** TODO Existing\n\n" - "** 2026-04-09 Thursday\n") - (goto-char (point-min)) - (re-search-forward "^\\*\\* 2026-04-09 Thursday$") - (goto-char (match-beginning 0)) - (ss-journal-ensure-day-sections) - (should (string-match-p - (regexp-quote - "** 2026-04-09 Thursday\n*** Tasks\n*** Notes\n*** Meetings\n") - (buffer-string))))) - -(ert-deftest ss-open-journal-narrows-to-today-when-entry-exists () - (let* ((file (make-temp-file "ss-journal" nil ".org")) - (ss-journal-file file) - (test-time (encode-time 0 0 12 9 4 2026))) - (unwind-protect - (cl-letf (((symbol-function 'current-time) - (lambda () - test-time))) - (with-temp-file file - (insert "#+title: Journal\n" - "* 2026\n" - "** 2026-04-09 Thursday\n" - "*** Notes\n")) - (ss-open-journal) - (should (buffer-narrowed-p)) - (should (equal (org-get-outline-path t) - '("2026" "2026-04-09 Thursday"))) - (should (looking-at-p "^\\*\\* 2026-04-09 Thursday$"))) - (when-let ((buffer (get-file-buffer file))) - (kill-buffer buffer)) - (when (file-exists-p file) - (delete-file file))))) - -(ert-deftest ss-open-journal-reveals-folded-today-subtree () - (let* ((file (make-temp-file "ss-journal" nil ".org")) - (ss-journal-file file) - (test-time (encode-time 0 0 12 9 4 2026))) - (unwind-protect - (cl-letf (((symbol-function 'current-time) - (lambda () - test-time))) - (with-temp-file file - (insert "#+title: Journal\n" - "* 2026\n" - "** 2026-04-09 Thursday\n" - "*** Notes\n" - "Body\n")) - (with-current-buffer (find-file-noselect file) - (org-overview)) - (ss-open-journal) - (should (buffer-narrowed-p)) - (should-not - (save-excursion - (goto-char (point-min)) - (re-search-forward "^\\*\\*\\* Notes$" nil t) - (invisible-p (point)))) - (should-not - (save-excursion - (goto-char (point-min)) - (re-search-forward "^Body$" nil t) - (invisible-p (point))))) - (when-let ((buffer (get-file-buffer file))) - (kill-buffer buffer)) - (when (file-exists-p file) - (delete-file file))))) - -(ert-deftest ss-open-journal-creates-missing-today-entry-with-standard-sections () - (let* ((file (make-temp-file "ss-journal" nil ".org")) - (ss-journal-file file) - (test-time (encode-time 0 0 12 9 4 2026))) - (unwind-protect - (cl-letf (((symbol-function 'current-time) - (lambda () - test-time))) - (with-temp-file file - (insert "#+title: Journal\n" - "* 2026\n" - "** 2026-04-08 Wednesday\n" - "*** Notes\n")) - (ss-open-journal) - (should (buffer-narrowed-p)) - (should (equal (org-get-outline-path t) - '("2026" "2026-04-09 Thursday"))) - (should (string-match-p - (regexp-quote - "** 2026-04-09 Thursday\n*** Tasks\n*** Notes\n*** Meetings\n") - (buffer-string)))) - (when-let ((buffer (get-file-buffer file))) - (kill-buffer buffer)) - (when (file-exists-p file) - (delete-file file))))) - -;;; ss-capture-tests.el ends here |
