1 ;;; test-org-feed.el --- Tests for org-feed.el -*- lexical-binding: t; -*-
3 ;; Copyright (C) 2016 Michael Brand
5 ;; Author: Michael Brand <michael.ch.brand@gmail.com>
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 3 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/>.
22 ;; Unit tests for Org Feed library.
28 (ert-deftest test-org-feed
/fill-template
()
29 "Test `org-feed-format-entry' template specifications."
31 ;; When working on these tests consider to also change
32 ;; `test-org-capture/fill-template'.
34 ;; %(sexp) placeholder.
37 (org-feed-format-entry nil
"%(concat \"success\" \"!\")" nil
)))
40 (equal "[[http://orgmode.org]]\n"
41 (org-feed-format-entry '(:link
"http://orgmode.org") "%a" nil
)))
42 ;; %t and %T placeholders.
44 (equal (format-time-string (org-time-stamp-format nil nil
))
45 (org-feed-format-entry nil
"%t" nil
)))
49 (org-feed-format-entry
50 '(:pubDate
"Sat, 02 Jan 2016 12:00:00 +0000") "%t" nil
)))
52 (equal (format-time-string (org-time-stamp-format t nil
))
53 (org-feed-format-entry nil
"%T" nil
)))
56 "<2016-01-02 \\S-+ 12:00>"
57 (org-feed-format-entry
58 '(:pubDate
"Sat, 02 Jan 2016 12:00:00 +0000") "%T" nil
)))
59 ;; %u and %U placeholders.
61 (equal (format-time-string (org-time-stamp-format nil t
))
62 (org-feed-format-entry nil
"%u" nil
)))
66 (org-feed-format-entry
67 '(:pubDate
"Sat, 02 Jan 2016 12:00:00 +0000") "%u" nil
)))
69 (equal (format-time-string (org-time-stamp-format t t
))
70 (org-feed-format-entry nil
"%U" nil
)))
73 "[2016-01-02 \\S-+ 12:00]"
74 (org-feed-format-entry
75 '(:pubDate
"Sat, 02 Jan 2016 12:00:00 +0000") "%U" nil
)))
76 ;; %h placeholder. Make sure sexp placeholders are not expanded
77 ;; when they are inserted through this one.
80 (org-feed-format-entry '(:title
"success!") "%h" nil
)))
82 (equal "%(concat \"no \" \"evaluation\")"
83 (org-feed-format-entry
84 '(:title
"%(concat \"no \" \"evaluation\")") "%h" nil
)))
85 ;; Test %-escaping with \ character.
88 (org-feed-format-entry '(:title
"success!") "\\%h" nil
)))
91 (org-feed-format-entry '(:title
"success!") "\\\\%h" nil
)))
94 (org-feed-format-entry '(:title
"success!") "\\\\\\%h" nil
)))
95 ;; More than one placeholder in the same template.
97 (equal "success! success! success! success!"
98 (org-feed-format-entry '(:title
"success!") "%h %h %h %h" nil
)))
99 ;; %(sexp) placeholder with an input containing the traps %, ", )
100 ;; and \n all at once which is complicated to parse.
103 "5 % Less (See\n Item \"3)\" Somewhere)"
104 (org-feed-format-entry
105 '(:title
"5 % less (see\n item \"3)\" somewhere)")
106 "%(capitalize \"%h\")" nil
))))
111 (provide 'test-org-feed
)
112 ;;; test-org-feed.el ends here