blob: b91d4efdeef9ff1d2ec3368d6e7a251b5d36cc1b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
;;; 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-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))
(unwind-protect
(progn
(with-temp-file file
(insert "#+title: Journal\n"
"* 2026\n"
"** 2026-04-09 Thursday\n"
"*** Notes\n"))
(let ((org-overriding-default-time (encode-time 0 0 12 9 4 2026)))
(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 (buffer-live-p (current-buffer))
(kill-buffer (current-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))
(unwind-protect
(progn
(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))
(let ((org-overriding-default-time (encode-time 0 0 12 9 4 2026)))
(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 (buffer-live-p (current-buffer))
(kill-buffer (current-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))
(unwind-protect
(progn
(with-temp-file file
(insert "#+title: Journal\n"
"* 2026\n"
"** 2026-04-08 Wednesday\n"
"*** Notes\n"))
(let ((org-overriding-default-time (encode-time 0 0 12 9 4 2026)))
(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 (buffer-live-p (current-buffer))
(kill-buffer (current-buffer)))
(when (file-exists-p file)
(delete-file file)))))
;;; ss-capture-tests.el ends here
|