branch: externals/denote
commit c0bcc13ef399cb256b7879a604935457719345a8
Author: Protesilaos Stavrou <i...@protesilaos.com>
Commit: Protesilaos Stavrou <i...@protesilaos.com>

    Write test for denote-sequence--get-new-sibling given commit 43322b3
---
 tests/denote-test.el | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/tests/denote-test.el b/tests/denote-test.el
index 0e2b6b2c97..857cc15ef4 100644
--- a/tests/denote-test.el
+++ b/tests/denote-test.el
@@ -614,6 +614,39 @@ does not involve the time zone."
       (equal (denote-sequence--get-new-child "2" sequences) "2=1")))
     (should-error (denote-sequence--get-new-child "3" sequences))
     (delete-directory denote-directory :delete-contents-as-well)))
+
+(ert-deftest denote-test--denote-sequence--get-new-sibling ()
+  "Make sure `denote-sequence--get-new-sibling' gets the sibling of a 
sequence."
+  (let* ((denote-directory (expand-file-name "denote-test" 
temporary-file-directory))
+         (files
+          (mapcar
+           (lambda (file)
+             (let ((path (expand-file-name file (denote-directory))))
+               (if (file-exists-p path)
+                   path
+                 (with-current-buffer (find-file-noselect path)
+                   (save-buffer)
+                   (kill-buffer (current-buffer)))
+                 path)))
+           '("20241230T075004==1--some-new-title__testing.txt"
+             "20241230T075023==1=1--sibling-of-note__testing.txt"
+             "20241230T075023==1=1=1--test__testing.txt"
+             "20241230T075023==1=1=2--test__testing.txt"
+             "20241230T075023==1=2--test__testing.txt"
+             "20241230T075023==1=2=1--test__testing.txt"
+             "20241230T075023==2--test__testing.txt")))
+         (sequences (denote-sequence-get-all-sequences files)))
+    (should
+     (and
+      (equal (denote-sequence--get-new-sibling "1" sequences) "3")
+      (equal (denote-sequence--get-new-sibling "1=1" sequences) "1=3")
+      (equal (denote-sequence--get-new-sibling "1=1=1" sequences) "1=1=3")
+      (equal (denote-sequence--get-new-sibling "1=1=2" sequences) "1=1=3")
+      (equal (denote-sequence--get-new-sibling "1=2" sequences) "1=3")
+      (equal (denote-sequence--get-new-sibling "1=2=1" sequences) "1=2=2")
+      (equal (denote-sequence--get-new-sibling "2" sequences) "3")))
+    (should-error (denote-sequence--get-new-sibling "4" sequences))
+    (delete-directory denote-directory :delete-contents-as-well)))
                  
 (provide 'denote-test)
 ;;; denote-test.el ends here

Reply via email to