123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- (ert-deftest test-org-archive/update-status-cookie ()
- "Test archiving properly updating status cookies."
-
- (should
- (equal
- "Top [0%]"
- (org-test-with-temp-text-in-file
- "* Top [%]\n** DONE One\n** TODO Two"
- (forward-line)
- (org-archive-subtree)
- (forward-line -1)
- (org-element-property :title (org-element-at-point)))))
-
- (should
- (equal
- "Top [100%]"
- (org-test-with-temp-text-in-file "* Top [%]\n** TODO Two"
- (forward-line)
- (org-archive-subtree)
- (forward-line -1)
- (org-element-property :title (org-element-at-point)))))
-
- (should
- (equal
- "Top [100%]"
- (org-test-with-temp-text "* Top [%]\n<point>** TODO One\n** DONE Two"
- (org-archive-to-archive-sibling)
- (forward-line -1)
- (org-element-property :title (org-element-at-point)))))
-
- (should
- (equal
- "Top [0%]"
- (org-test-with-temp-text "* Top [%]\n<point>** DONE Two"
- (org-archive-to-archive-sibling)
- (forward-line -1)
- (org-element-property :title (org-element-at-point))))))
- (ert-deftest test-org-archive/datetree ()
- "Test `org-archive-subtree' with a datetree target."
- (org-test-at-time "<2020-07-05 Sun>"
-
- (should
- (string-match-p
- (regexp-quote (format-time-string "*** 2020-07-05 %A\n**** a"))
- (org-test-with-temp-text-in-file "* a\n"
- (let ((org-archive-location "::datetree/"))
- (org-archive-subtree)
- (buffer-string)))))
-
- (should
- (string-match-p
- (regexp-quote (format-time-string "***** 2020-07-05 %A\n******* a"))
- (org-test-with-temp-text-in-file "* a\n"
- (let ((org-archive-location "::datetree/")
- (org-odd-levels-only t))
- (org-archive-subtree)
- (buffer-string)))))
-
- (should
- (string-match-p
- (regexp-quote (format-time-string "*** 2020-07-05 %A\n**** a\n***** b"))
- (org-test-with-temp-text-in-file "* b\n"
- (let ((org-archive-location "::datetree/* a"))
- (org-archive-subtree)
- (buffer-string)))))
-
- (should
- (string-match-p
- (regexp-quote (format-time-string "***** 2020-07-05 %A\n******* a\n********* b"))
- (org-test-with-temp-text-in-file "* b\n"
- (let ((org-archive-location "::datetree/* a")
- (org-odd-levels-only t))
- (org-archive-subtree)
- (buffer-string)))))))
- (ert-deftest test-org-archive/to-archive-sibling ()
- "Test `org-archive-to-archive-sibling' specifications."
-
- (should
- (equal "* Archive :ARCHIVE:\n** H\n"
- (org-test-with-temp-text "* H\n* Archive :ARCHIVE:\n"
- (let ((org-archive-sibling-heading "Archive")
- (org-archive-tag "ARCHIVE"))
- (org-archive-to-archive-sibling)
- (goto-char (point-min))
- (buffer-substring-no-properties
- (point) (line-beginning-position 3))))))
- (should
- (equal "* Archive :ARCHIVE:\n** H\n"
- (org-test-with-temp-text "* Archive :ARCHIVE:\n<point>* H\n"
- (let ((org-archive-sibling-heading "Archive")
- (org-archive-tag "ARCHIVE"))
- (org-archive-to-archive-sibling)
- (goto-char (point-min))
- (buffer-substring-no-properties
- (point) (line-beginning-position 3))))))
-
- (should
- (equal "* Archive :ARCHIVE:\n** H\n"
- (org-test-with-temp-text "* H\n"
- (let ((org-archive-sibling-heading "Archive")
- (org-archive-tag "ARCHIVE")
- (org-tags-column 1))
- (org-archive-to-archive-sibling)
- (goto-char (point-min))
- (buffer-substring-no-properties
- (point) (line-beginning-position 3))))))
-
- (should
- (equal "* Archive :ARCHIVE:\n* Top\n** Archive :ARCHIVE:\n*** H\n"
- (org-test-with-temp-text "* Archive :ARCHIVE:\n* Top\n<point>** H\n"
- (let ((org-archive-sibling-heading "Archive")
- (org-archive-tag "ARCHIVE")
- (org-tags-column 0))
- (org-archive-to-archive-sibling)
- (goto-char (point-min))
- (buffer-substring-no-properties
- (point) (line-beginning-position 5))))))
-
- (should
- (equal "* H2"
- (org-test-with-temp-text "* H1\n* H2\n* Archive :ARCHIVE:\n"
- (let ((org-archive-sibling-heading "Archive")
- (org-archive-tag "ARCHIVE"))
- (org-archive-to-archive-sibling)
- (buffer-substring-no-properties (point) (line-end-position))))))
- (should
- (equal "* H2"
- (org-test-with-temp-text "* Archive :ARCHIVE:\n<point>* H1\n* H2\n"
- (let ((org-archive-sibling-heading "Archive")
- (org-archive-tag "ARCHIVE"))
- (org-archive-to-archive-sibling)
- (buffer-substring-no-properties (point) (line-end-position))))))
-
-
- (should
- (equal "* Archive :ARCHIVE:\n** A\n"
- (org-test-with-temp-text "* H\n* Archive :ARCHIVE:\n** A\n"
- (let ((org-archive-sibling-heading "Archive")
- (org-archive-tag "ARCHIVE")
- (org-archive-reversed-order nil))
- (org-archive-to-archive-sibling)
- (goto-char (point-min))
- (buffer-substring-no-properties
- (point) (line-beginning-position 3))))))
- (should
- (equal "* Archive :ARCHIVE:\n** H\n"
- (org-test-with-temp-text "* H\n* Archive :ARCHIVE:\n** A\n"
- (let ((org-archive-sibling-heading "Archive")
- (org-archive-tag "ARCHIVE")
- (org-archive-reversed-order t))
- (org-archive-to-archive-sibling)
- (goto-char (point-min))
- (buffer-substring-no-properties
- (point) (line-beginning-position 3)))))))
- (provide 'test-org-archive)
|