diff --git a/Makefile b/Makefile index c146042..8e72b13 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -.PHONY: all fast clean help +.PHONY: all fast clean tests help # Default target: full build with search index all: @@ -15,10 +15,15 @@ clean: @echo "Cleaning output directory..." rm -rf output/ +tests: + @echo "Running all the tests..." + emacs -batch -l ert -l tests/macros-tests.el -f ert-run-tests-batch-and-exit + # Show help message help: @echo "Available targets:" @echo " make - Full rebuild (with search index)" @echo " make fast - Fast rebuild (without search index)" @echo " make clean - Remove output directory" + @echo " make tests - Run all of the tests associated with the project" @echo " make help - Show this help message" diff --git a/tests/build-tests.el b/tests/build-tests.el new file mode 100644 index 0000000..1df8e46 --- /dev/null +++ b/tests/build-tests.el @@ -0,0 +1 @@ +(require 'ert) diff --git a/tests/build-tests.el~ b/tests/build-tests.el~ new file mode 100644 index 0000000..e69de29 diff --git a/tests/macros-tests.el b/tests/macros-tests.el new file mode 100644 index 0000000..2fb4500 --- /dev/null +++ b/tests/macros-tests.el @@ -0,0 +1,59 @@ +(require 'ert) +(require 'ox-html) +(load-file "~/master-folder/org_files/org_roam/macros.el") + +(defun helper/org-export-html (org-content) + "Export ORG-CONTENT string to HTML and return the result." + (with-temp-buffer + (insert org-content) + (org-mode) + (org-export-as 'html nil nil t))) + + +(ert-deftest test/org-macro-sidenote () + (let ((html (helper/org-export-html + "Here is a sidenote {{{sidenote(This is a note)}}}.")) + (expected "This is a note") + ) + (should + (string-match-p expected html)))) + +(ert-deftest test/org-macro-epigraph-single () + (let ((html (helper/org-export-html + "{{{epigraph_single(To be is to do.,Socrates)}}}"))) + (should + (string-match-p + "
" + html)) + (should + (string-match-p + "To be is to do\\.
" + html)) + (should + (string-match-p + "" + html)))) + +(ert-deftest test/org-macro-epigraph-multiline () + (let ((html (helper/org-export-html + "{{{epigraph(Line one.
Line two.
)}}}"))) + (should + (string-match-p + "" + html)) + (should + (string-match-p + "Line one\\." + html)) + (should + (string-match-p + "Line two\\." + html)))) + +(ert-deftest test/org-macro-newthought () + (let ((html (helper/org-export-html + "{{{newthought(Attention)}}} is important."))) + (should + (string-match-p + "Attention" + html)))) diff --git a/tests/macros-tests.el~ b/tests/macros-tests.el~ new file mode 100644 index 0000000..e69de29