]> gitweb.fperrin.net Git - atom.git/blobdiff - atom-tests.el
Use plist for optional arguments
[atom.git] / atom-tests.el
index 3c5330c7b4e2058637d631cc95f735384f7c49f4..a725a55ac3d607f7bc9e5e04d9870a1a2a3a8218 100644 (file)
 (ert-deftest text-feed ()
   (let* ((user-full-name "John Smith")
         (user-mail-address "john.smith@example.org")
-        (my-atom-feed (atom-create "My feed" "http://example.org"))
-        (now (current-time)))
+        (now (current-time))
+        (my-atom-feed (atom-create "My feed" "http://example.org"
+                                   (list :updated now))))
     ;; A simple, text-only entry
     (atom-add-text-entry
      my-atom-feed
      "Hello world"
      "http://example.org/hello"
      "Hello the world!"
-     now)
+     (list :updated now))
 
     ;; <?xml version="1.0" encoding="utf-8"?>
     ;; <feed xmlns="http://www.w3.org/2005/Atom">
          (goto-char (point-min))
          (should (re-search-forward exp-string))))
       (goto-char (point-min))
+      ;; there will be two updated elements, for the feed and the entry
+      (re-search-forward "updated>\\(.*\\)</updated>")
+      (let* ((updated-string (match-string 1))
+            (updated-time (atom-parse-time updated-string)))
+       (should (equal updated-time (seq-take now 2))))
       (re-search-forward "updated>\\(.*\\)</updated>")
       (let* ((updated-string (match-string 1))
             (updated-time (atom-parse-time updated-string)))
 
 (ert-deftest atom-opt-elements ()
   (let ((my-atom-feed (atom-create "My Feed" "http://example.org"
-                                  "Feed subtitle" ; subtitle
-                                  "http://example.org/feed.atom" ; self link
-                                  "urn:example-id" ; id
-                                  (cons "Author name" "Author addr")
-                                  "2024-04-23T01:02:03+04:00" ; updated
-                                  )))
+                                  (list :subtitle "Feed subtitle"
+                                        :self "http://example.org/feed.atom"
+                                        :id "urn:example-id:1"
+                                        :author (list "Author name" "Author@example.org")
+                                        :updated (atom-parse-time "2024-03-23T01:02:03+04:00")))))
     (atom-add-text-entry
      my-atom-feed
      "A text entry"
      "http://example.org/text"
      "Some text"
-     "2024-04-23T01:02:03+04:00" ; updated
-     (atom-generate-id "http://example.org/text" (current-time)))))
+     (list :updated (atom-parse-time "2024-03-23T01:02:04+0400")
+          :summary "summary"))
+    (atom-add-html-entry
+     my-atom-feed
+     "A HTLM entry"
+     "http://example.org/html"
+     "<p>Some text</p>"
+     (list :updated (atom-parse-time "2024-03-23T01:02:05+04:00")
+          :summary "<p>summary...</p>"))
+    (atom-add-xhtml-entry
+     my-atom-feed
+     "A XHTML entry"
+     "http://example.org/xhtml"
+     "<p>Some text</p>"
+     (list :updated (atom-parse-time "2024-03-23T01:02:06+04:00")
+          :summary "<p>summary...</p>"))
+
+    (atom-print my-atom-feed)
+    (atom-print-as-rss my-atom-feed)))
 
 (provide 'atom-tests)
 ;;; atom-tests.el ends here