diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-05 07:04:37 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-05 07:04:37 -0500 |
| commit | 4fa136a0f8bfde7852655a9fce2c44422bd32b3a (patch) | |
| tree | 5e5029e640cc003c58a022471a9c631fd628d2bf /tests/test-calendar-sync--apply-single-exception.el | |
| parent | 10e2929d5be68ec1fda8b5b4ed08511eac02e7b3 (diff) | |
test(calendar-sync): add 32 tests for recurrence exceptions, helpers, unfolding
Cover occurrence-matches-exception-p (6), apply-single-exception (6),
exdate-matches-p (6), extract-cn (5), extract-email (4), unfold-continuation (5).
Diffstat (limited to 'tests/test-calendar-sync--apply-single-exception.el')
| -rw-r--r-- | tests/test-calendar-sync--apply-single-exception.el | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/test-calendar-sync--apply-single-exception.el b/tests/test-calendar-sync--apply-single-exception.el new file mode 100644 index 00000000..2fcf7c71 --- /dev/null +++ b/tests/test-calendar-sync--apply-single-exception.el @@ -0,0 +1,67 @@ +;;; test-calendar-sync--apply-single-exception.el --- Tests for exception application -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for calendar-sync--apply-single-exception. +;; Applies exception overrides to an occurrence plist, returning a modified copy. + +;;; Code: + +(require 'ert) +(require 'testutil-calendar-sync) +(require 'calendar-sync) + +;;; Normal Cases + +(ert-deftest test-calendar-sync--apply-single-exception-normal-updates-time () + "Exception start/end override the occurrence times." + (let ((occ (list :start '(2026 3 15 14 0) :end '(2026 3 15 15 0) + :summary "Standup" :uid "abc")) + (exc (list :start '(2026 3 15 16 0) :end '(2026 3 15 17 0)))) + (let ((result (calendar-sync--apply-single-exception occ exc))) + (should (equal '(2026 3 15 16 0) (plist-get result :start))) + (should (equal '(2026 3 15 17 0) (plist-get result :end)))))) + +(ert-deftest test-calendar-sync--apply-single-exception-normal-updates-summary () + "Exception with summary overrides the occurrence summary." + (let ((occ (list :start '(2026 3 15 14 0) :summary "Original")) + (exc (list :start '(2026 3 15 14 0) :summary "Modified"))) + (let ((result (calendar-sync--apply-single-exception occ exc))) + (should (equal "Modified" (plist-get result :summary)))))) + +(ert-deftest test-calendar-sync--apply-single-exception-normal-preserves-unset-fields () + "Fields not present in exception are preserved from occurrence." + (let ((occ (list :start '(2026 3 15 14 0) :summary "Keep" :uid "abc" + :location "Room 1")) + (exc (list :start '(2026 3 15 16 0)))) + (let ((result (calendar-sync--apply-single-exception occ exc))) + (should (equal "Keep" (plist-get result :summary))) + (should (equal "abc" (plist-get result :uid))) + (should (equal "Room 1" (plist-get result :location)))))) + +;;; Boundary Cases + +(ert-deftest test-calendar-sync--apply-single-exception-boundary-nil-end () + "Exception without :end preserves occurrence :end." + (let ((occ (list :start '(2026 3 15 14 0) :end '(2026 3 15 15 0))) + (exc (list :start '(2026 3 15 16 0)))) + (let ((result (calendar-sync--apply-single-exception occ exc))) + (should (equal '(2026 3 15 15 0) (plist-get result :end)))))) + +(ert-deftest test-calendar-sync--apply-single-exception-boundary-does-not-mutate () + "Original occurrence plist is not mutated." + (let ((occ (list :start '(2026 3 15 14 0) :summary "Original")) + (exc (list :start '(2026 3 15 16 0) :summary "Changed"))) + (calendar-sync--apply-single-exception occ exc) + (should (equal "Original" (plist-get occ :summary))))) + +;;; Error Cases + +(ert-deftest test-calendar-sync--apply-single-exception-error-empty-exception () + "Exception with no fields still returns a valid plist with occurrence data." + (let ((occ (list :start '(2026 3 15 14 0) :summary "Keep")) + (exc (list :start nil))) + (let ((result (calendar-sync--apply-single-exception occ exc))) + (should (equal "Keep" (plist-get result :summary)))))) + +(provide 'test-calendar-sync--apply-single-exception) +;;; test-calendar-sync--apply-single-exception.el ends here |
