From 128173bca68b579499a2b01a9e7d64fa96a9b192 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Mon, 31 Mar 2014 20:16:37 -0400 Subject: Add functions to sort topic headings --- bog-tests.el | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) (limited to 'bog-tests.el') 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"))))) -- cgit v1.2.3