1 ;;; pelican-mode-test.el --- Tests pelican-mode -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2017 Joe Wreschnig
5 ;; Author: Joe Wreschnig
7 ;; This program is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation, either version 2 of the License, or
10 ;; (at your option) any later version.
12 ;; This program is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with this program. If not, see <http://www.gnu.org/licenses/>.
24 ;; This file contains test cases for pelican-mode. Unless you’re
25 ;; hacking on it you shouldn’t need to edit or run this file.
32 (require 'pelican-mode)
34 (defun pelican-mode-test-article (mode expected1 expected2)
35 "Create an article in MODE and perform some edits.
37 After the first edits, the buffer should contain EXPECTED1; after
38 the second, EXPECTED2."
40 (rename-buffer "pelican-test.rst")
44 (should (not (pelican-mode-find-root)))
45 (should (not (pelican-mode-page-p)))
46 (should (equal "pelican-test" (pelican-mode-default-slug)))
48 (insert "Not really a Pelican article.")
49 (pelican-mode-insert-article-header "Testing" "a, b, c")
50 (pelican-mode-set-field :test "hello world")
51 (pelican-mode-set-field :date "1111-11-11 11:11:11")
52 (should (equal (buffer-string) expected1))
54 (pelican-mode-publish)
55 (pelican-mode-set-fields
57 :date "2222-22-22 22:22:22")
58 (pelican-mode-remove-field "test")
59 (should (equal (buffer-string) expected2))))
61 (ert-deftest pelican-mode-test-rst-mode ()
62 (pelican-mode-test-article
68 :date: 1111-11-11 11:11:11
74 Not really a Pelican article."
80 :date: 2222-22-22 22:22:22
84 Not really a Pelican article."))
86 (ert-deftest pelican-mode-test-org-mode ()
87 (pelican-mode-test-article
91 #+DATE: 1111-11-11 11:11:11
92 #+PROPERTY: STATUS draft
93 #+PROPERTY: SLUG pelican-test
94 #+PROPERTY: TAGS a, b, c
95 #+PROPERTY: TEST hello world
97 Not really a Pelican article."
101 #+DATE: 2222-22-22 22:22:22
102 #+PROPERTY: SLUG pelican-test
103 #+PROPERTY: TAGS a, b, c
105 Not really a Pelican article."))
107 ;;; pelican-mode-test.el ends here