diff --git a/tests/roam-files/promoteable.org b/tests/roam-files/promoteable.org new file mode 100644 index 0000000..d6b5290 --- /dev/null +++ b/tests/roam-files/promoteable.org @@ -0,0 +1,3 @@ +* Promoteable h1 + +** Promoteable child diff --git a/tests/test-org-roam-node.el b/tests/test-org-roam-node.el new file mode 100644 index 0000000..4677c3f --- /dev/null +++ b/tests/test-org-roam-node.el @@ -0,0 +1,62 @@ +;;; test-org-roam-node.el --- Tests for Org-roam -*- lexical-binding: t; -*- + +;; Copyright (C) 2020 Jethro Kuan + +;; Author: Jethro Kuan +;; Package-Requires: ((buttercup)) + +;; This program is free software; you can redistribute it and/or modify +;; it under the terms of the GNU General Public License as published by +;; the Free Software Foundation, either version 3 of the License, or +;; (at your option) any later version. + +;; This program is distributed in the hope that it will be useful, +;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;; GNU General Public License for more details. + +;; You should have received a copy of the GNU General Public License +;; along with this program. If not, see . + +;;; Commentary: +;;; Code: + +(require 'buttercup) +(require 'org-roam) + +(defvar root-directory default-directory) + +(describe "org-roam--h1-count" + (after-each + (cd root-directory)) + + (it "returns the correct number of level-1 headings" + (find-file "tests/roam-files/foo.org" nil) + (expect (org-roam--h1-count) :to-equal 0) + + (cd root-directory) + + (find-file "tests/roam-files/family.org" nil) + (expect (org-roam--h1-count) :to-equal 1))) + +(describe "org-roam--buffer-promoteable-p" + (after-each + (cd root-directory)) + + (it "should check if buffer is promoteable" + (find-file "tests/roam-files/foo.org" nil) + (expect (org-roam--buffer-promoteable-p) :to-equal nil) + + (cd root-directory) + + (find-file "tests/roam-files/family.org" nil) + (expect (org-roam--buffer-promoteable-p) :to-equal nil) + + (cd root-directory) + + (find-file "tests/roam-files/promoteable.org" nil) + (expect (org-roam--buffer-promoteable-p) :to-equal t))) + +(provide 'test-org-roam-node) + +;;; test-org-roam-node.el ends here diff --git a/tests/test-org-roam.el b/tests/test-org-roam.el index 4133fb7..b4930c9 100644 --- a/tests/test-org-roam.el +++ b/tests/test-org-roam.el @@ -36,18 +36,17 @@ (delete-file org-roam-db-location)) (it "gets files correctly" - (expect (length (org-roam-list-files)) - :to-equal 5)) + (expect (length (org-roam-list-files)) :to-equal 6)) (it "respects org-roam-file-extensions" (setq org-roam-file-extensions '("md")) (expect (length (org-roam-list-files)) :to-equal 1) (setq org-roam-file-extensions '("org" "md")) - (expect (length (org-roam-list-files)) :to-equal 6)) + (expect (length (org-roam-list-files)) :to-equal 7)) (it "respects org-roam-file-exclude-regexp" (setq org-roam-file-exclude-regexp (regexp-quote "foo.org")) - (expect (length (org-roam-list-files)) :to-equal 4))) + (expect (length (org-roam-list-files)) :to-equal 5))) (describe "org-roam-db-sync" (before-all @@ -64,7 +63,7 @@ (it "has the correct number of files" (expect (caar (org-roam-db-query [:select (funcall count) :from files])) :to-equal - 5)) + 6)) (it "has the correct number of nodes" (expect (caar (org-roam-db-query [:select (funcall count) :from nodes]))