aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authorSpencer Williams <spnw@plexwave.org>2025-07-07 12:54:49 -0400
committerSpencer Williams <spnw@plexwave.org>2025-07-07 12:54:49 -0400
commite5f58a411e3343a27fb6c1787bc9404d89cc0309 (patch)
treed7bab6d9dd048c3755c00cc9f62debc3bb2b4d55 /lisp
parent35f68553dc8b392f760733c438b084996fa5fa44 (diff)
Add tests for draft feature
Diffstat (limited to 'lisp')
-rw-r--r--lisp/seam-test.el67
1 files changed, 63 insertions, 4 deletions
diff --git a/lisp/seam-test.el b/lisp/seam-test.el
index 4907b51..a063758 100644
--- a/lisp/seam-test.el
+++ b/lisp/seam-test.el
@@ -42,6 +42,7 @@
`(let* ((seam-test-directory (file-name-as-directory (make-temp-file "seam-test" t)))
(seam-note-directory seam-test-directory)
(default-directory seam-test-directory)
+ (seam-create-as-draft nil)
(seam-note-types '("private" "public"))
(seam-default-note-type "private")
(seam-title-formatter (lambda (title _type _draft-p) title))
@@ -204,12 +205,14 @@
(ert-deftest seam-test-buffer-name-format-custom ()
(should
(equal
- "[private] Note"
+ "[private draft] Note"
(seam-test-with-notes ((seam-title-formatter
- (lambda (title type _draft-p)
- (format "[%s] %s" type title))))
+ (lambda (title type draft-p)
+ (format "[%s%s] %s" type (if draft-p " draft" "") title))))
((note "Note"))
- (buffer-name note)))))
+ (with-current-buffer note
+ (call-interactively 'seam-toggle-draft)
+ (buffer-name note))))))
(ert-deftest seam-test-link-update ()
"Test that renaming a note updates its HTML and that of notes which link to it."
@@ -401,6 +404,62 @@ update linking HTML files such that they link to it."
((foo "foo"))
(seam-set-note-type (buffer-file-name foo) "invalid-type"))))
+(ert-deftest seam-test-create-draft ()
+ (should
+ (equal
+ '("public/-note.org")
+ (seam-test-with-notes ((seam-create-as-draft t))
+ ((note "Note" "public"))
+ (seam-test-list-files)))))
+
+(ert-deftest seam-test-create-draft-override ()
+ (should
+ (equal
+ '("public/-note.org")
+ (seam-test-with-notes ((seam-note-types
+ '(("public" :create-as-draft t))))
+ ((note "Note" "public"))
+ (seam-test-list-files)))))
+
+(ert-deftest seam-test-set-draft ()
+ "Test that toggling a note from non-draft to draft will delete its
+HTML file and update linking HTML files such that they no longer
+link to it."
+ (should
+ (equal
+ '(nil ("html/foo.html" "public/-bar.org" "public/foo.org"))
+ (seam-test-with-notes ()
+ ((foo "foo" "public")
+ (bar "bar" "public"))
+ (with-current-buffer foo
+ (seam-test-add-contents foo (seam-test-link-to-buffer bar)))
+ (with-current-buffer bar
+ (call-interactively 'seam-toggle-draft))
+ (list
+ (seam-test-links-from-html "html/foo.html")
+ (seam-test-list-files))))))
+
+;;; NOTE: This is the same test as `seam-test-set-draft', except that
+;;; we toggle bar's draft status twice.
+(ert-deftest seam-test-unset-draft ()
+ "Test that toggling a note from draft to non-draft will export its
+HTML file and update linking HTML files such that they link to
+it."
+ (should
+ (equal
+ '(("bar.html") ("html/bar.html" "html/foo.html" "public/bar.org" "public/foo.org"))
+ (seam-test-with-notes ()
+ ((foo "foo" "public")
+ (bar "bar" "public"))
+ (with-current-buffer foo
+ (seam-test-add-contents foo (seam-test-link-to-buffer bar)))
+ (with-current-buffer bar
+ (call-interactively 'seam-toggle-draft)
+ (call-interactively 'seam-toggle-draft))
+ (list
+ (seam-test-links-from-html "html/foo.html")
+ (seam-test-list-files))))))
+
(ert-deftest seam-test-follow-link-existing ()
"Test that following a link to an existing note opens that note."
(should