summaryrefslogtreecommitdiff
path: root/gnus-icalendar-request-tests.el
blob: c9eab69f6d278db29748e90594c7acf635163209 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
;;; 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 the vevent remains intact
      (should (string-match "^\\(BEGIN:VEVENT\\(\n\\|.\\)*\nEND:VEVENT\\)" vcalendar))
      (should (string-match (match-string 1 vcalendar) event)))
    (setenv "TZ" tz)))