branch: externals/denote commit 6a43e5cad555b51bd8784201c3c9deec8e74e2ad Author: Protesilaos Stavrou <i...@protesilaos.com> Commit: Protesilaos Stavrou <i...@protesilaos.com>
Add test about denote-sequence--get-new-child --- tests/denote-test.el | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/denote-test.el b/tests/denote-test.el index 0c6028b1b7..0e2b6b2c97 100644 --- a/tests/denote-test.el +++ b/tests/denote-test.el @@ -581,5 +581,39 @@ does not involve the time zone." (let ((denote-journal-extras-title-format 'day-date-month-year-24h)) (denote-journal-extras-daily--title-format)))))) +;;;; denote-sequence.el + +(ert-deftest denote-test--denote-sequence--get-new-child () + "Make sure `denote-sequence--get-new-child' gets the child 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--child-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-child "1" sequences) "1=3") + (equal (denote-sequence--get-new-child "1=1" sequences) "1=1=3") + (equal (denote-sequence--get-new-child "1=1=2" sequences) "1=1=2=1") + (equal (denote-sequence--get-new-child "1=2" sequences) "1=2=2") + (equal (denote-sequence--get-new-child "1=2=1" sequences) "1=2=1=1") + (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))) + (provide 'denote-test) ;;; denote-test.el ends here