summaryrefslogtreecommitdiff
path: root/bog-tests.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2014-03-31 20:16:37 -0400
committerKyle Meyer <kyle@kyleam.com>2014-03-31 20:16:37 -0400
commit128173bca68b579499a2b01a9e7d64fa96a9b192 (patch)
tree30d13b08f8c9db82f5a6b661bad091130d91867e /bog-tests.el
parent4e240bd6f1569d9c304567992529f949b880fb04 (diff)
downloadbog-128173bca68b579499a2b01a9e7d64fa96a9b192.tar.gz
Add functions to sort topic headings
Diffstat (limited to 'bog-tests.el')
-rw-r--r--bog-tests.el89
1 files changed, 89 insertions, 0 deletions
diff --git a/bog-tests.el b/bog-tests.el
index f83c3af..0c737c4 100644
--- a/bog-tests.el
+++ b/bog-tests.el
@@ -239,3 +239,92 @@
(insert "abc1900word\nhij2000word\nefg1800word\n")
(should (equal (bog-collect-references t)
'("efg1800word" "hij2000word" "abc1900word")))))
+
+;; `bog-sort-topic-headings-in-buffer'
+
+(ert-deftest bog-sort-topic-headings-in-buffer ()
+ (with-temp-buffer
+ (let ((bog-topic-heading-level 1))
+ (insert "\n* topic heading\n\n"
+ "** zoo2000key\n\nsome text\n\n"
+ "** apple2000key\n\nsome text\n"
+ "* another topic heading\n\n"
+ "** orange2000key\n\nsome text\n\n"
+ "** banana2000key\n\nsome text\n"
+ "** yogurt2000key\n\nsome text\n")
+ (org-mode)
+ (show-all)
+ (bog-sort-topic-headings-in-buffer)
+ (goto-char 0)
+ (outline-next-visible-heading 2)
+ (should (equal (org-no-properties (org-get-heading t t))
+ "apple2000key"))
+ (outline-next-visible-heading 3)
+ (should (equal (org-no-properties (org-get-heading t t))
+ "banana2000key")))))
+
+(ert-deftest bog-sort-topic-headings-in-buffer-ignore-citekey-heading ()
+ (with-temp-buffer
+ (let ((bog-topic-heading-level 1))
+ (insert "\n* topic heading\n\n"
+ "** zoo2000key\n\nsome text\n\n"
+ "** apple2000key\n\nsome text\n"
+ "* citekey2000heading\n\n"
+ "** orange2000key\n\nsome text\n\n"
+ "** banana2000key\n\nsome text\n"
+ "** yogurt2000key\n\nsome text\n")
+ (org-mode)
+ (show-all)
+ (bog-sort-topic-headings-in-buffer)
+ (goto-char 0)
+ (outline-next-visible-heading 2)
+ (should (equal (org-no-properties (org-get-heading t t))
+ "apple2000key"))
+ (outline-next-visible-heading 3)
+ (should (equal (org-no-properties (org-get-heading t t))
+ "orange2000key")))))
+
+(ert-deftest bog-sort-topic-headings-in-buffer-ignore-citekey-property ()
+ (with-temp-buffer
+ (let ((bog-topic-heading-level 1))
+ (insert "\n* topic heading\n\n"
+ "** zoo2000key\n\nsome text\n\n"
+ "** apple2000key\n\nsome text\n"
+ "* non-topic heading\n"
+ " :PROPERTIES:\n"
+ (format " :%s: citekey2000prop\n" bog-citekey-property)
+ " :END:\n"
+ "** orange2000key\n\nsome text\n\n"
+ "** banana2000key\n\nsome text\n"
+ "** yogurt2000key\n\nsome text\n")
+ (org-mode)
+ (show-all)
+ (bog-sort-topic-headings-in-buffer)
+ (goto-char 0)
+ (outline-next-visible-heading 2)
+ (should (equal (org-no-properties (org-get-heading t t))
+ "apple2000key"))
+ (outline-next-visible-heading 3)
+ (should (equal (org-no-properties (org-get-heading t t))
+ "orange2000key")))))
+
+(ert-deftest bog-sort-topic-headings-in-buffer-passed-sorting-type ()
+ (with-temp-buffer
+ (let ((bog-topic-heading-level 1))
+ (insert "\n* topic heading\n\n"
+ "** zoo2000key\n\nsome text\n\n"
+ "** apple2000key\n\nsome text\n"
+ "* another topic heading\n\n"
+ "** orange2000key\n\nsome text\n\n"
+ "** banana2000key\n\nsome text\n"
+ "** yogurt2000key\n\nsome text\n")
+ (org-mode)
+ (show-all)
+ (bog-sort-topic-headings-in-buffer ?n)
+ (goto-char 0)
+ (outline-next-visible-heading 2)
+ (should (equal (org-no-properties (org-get-heading t t))
+ "zoo2000key"))
+ (outline-next-visible-heading 3)
+ (should (equal (org-no-properties (org-get-heading t t))
+ "orange2000key")))))