summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnus-icalendar-request-tests.el63
1 files changed, 63 insertions, 0 deletions
diff --git a/gnus-icalendar-request-tests.el b/gnus-icalendar-request-tests.el
new file mode 100644
index 0000000..c7d9751
--- /dev/null
+++ b/gnus-icalendar-request-tests.el
@@ -0,0 +1,63 @@
+;;; gnus-icalendar-request-tests.el --- tests -*- lexical-binding: t; -*-
+
+;; Copyright (C) 2024 Ferdinand Pieper
+
+;; Author: Ferdinand Pieper <mail@pie.tf>
+;; Keywords:
+
+;; This file is part of GNU Emacs.
+
+;; GNU Emacs 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.
+
+;; GNU Emacs 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 GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;;
+
+;;; Code:
+
+(require 'ert)
+(require 'gnus-icalendar-request)
+
+(ert-deftest gnus-icalendar-create-vcalendar ()
+ ""
+ (let ((tz (getenv "TZ"))
+ (event "\
+BEGIN:VEVENT
+DTSTAMP:20240915T120000Z
+DTSTART:20240917T080000Z
+DTEND:20240917T100000Z
+SUMMARY:Party
+DESCRIPTION:Lots of reasons to celebrate!
+ATTENDEE;PARTSTAT=NEEDS-ACTION;ROLE=REQ-PARTICIPANT;RSVP=TRUE:mailto:required@company.invalid
+ATTENDEE;PARTSTAT=NEEDS-ACTION;ROLE=OPT-PARTICIPANT;RSVP=TRUE:mailto:optional@company.invalid
+LOCATION:Party room
+ORGANIZER:mailto:organizer@company.invalid
+UID:ac44f43e-f5cd-4b0a-878e-add01aeb12dd
+SEQUENCE:0
+END:VEVENT"))
+ (setenv "TZ" "CET-1CEST,M3.5.0/2,M10.5.0/3")
+ (let ((vcalendar (gnus-icalendar--build-vcalendar-from-vevent event)))
+ ;; Ensure there is exactly one of version and prodid
+ (should (string-match "^VERSION:2.0\\(\n\\|.\\)*END:VCALENDAR" vcalendar))
+ (should-not (string-match "^VERSION:" (match-string 1 vcalendar)))
+ (should (string-match "^PRODID:\\(\n\\|.\\)*END:VCALENDAR" vcalendar))
+ (should-not (string-match "^PRODID:" (match-string 1 vcalendar)))
+ ;; Ensure we have a timezone entry
+ (should (string-match "^\\(BEGIN:VTIMEZONE\\(\n\\|.\\)*END:VTIMEZONE\\)" vcalendar))
+ (let ((vtimezone (match-string 1 vcalendar)))
+ )
+ ;; Ensure the vevent remains intact
+ (should (string-match "^\\(BEGIN:VEVENT\\(\n\\|.\\)*\nEND:VEVENT\\)" vcalendar))
+ (should (string-match (match-string 1 vcalendar) event)))
+ (setenv "TZ" tz)))