summaryrefslogtreecommitdiff
path: root/tests/test-calendar-sync--split-events.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-05 06:51:20 -0500
committerCraig Jennings <c@cjennings.net>2026-04-05 06:51:20 -0500
commit7eb6c0692d48b8c3d01efba8abcd2bfdfaa7cd31 (patch)
tree2af7aa512feaae39b384939160af68fa0537fc22 /tests/test-calendar-sync--split-events.el
parent47453fd03be79205c6209d31a26cb4f7724af317 (diff)
test(calendar-sync): add 68 tests across 13 files for untested pure functions
Covers core parsing (parse-ics-datetime, parse-timestamp, format-timestamp, split-events, parse-event), date utilities (add-months, add-days, weekday-to-number, date-weekday, event-start-time), and timezone (format-timezone-offset, convert-utc-to-local, localize-parsed-datetime).
Diffstat (limited to 'tests/test-calendar-sync--split-events.el')
-rw-r--r--tests/test-calendar-sync--split-events.el54
1 files changed, 54 insertions, 0 deletions
diff --git a/tests/test-calendar-sync--split-events.el b/tests/test-calendar-sync--split-events.el
new file mode 100644
index 00000000..a5a957c3
--- /dev/null
+++ b/tests/test-calendar-sync--split-events.el
@@ -0,0 +1,54 @@
+;;; test-calendar-sync--split-events.el --- Tests for VEVENT block splitter -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Tests for calendar-sync--split-events.
+;; Splits raw .ics content into individual VEVENT block strings.
+
+;;; Code:
+
+(require 'ert)
+(require 'testutil-calendar-sync)
+(require 'calendar-sync)
+
+;;; Normal Cases
+
+(ert-deftest test-calendar-sync--split-events-normal-single ()
+ "Single VEVENT returns one-element list."
+ (let* ((ics "BEGIN:VCALENDAR\nBEGIN:VEVENT\nSUMMARY:Test\nEND:VEVENT\nEND:VCALENDAR")
+ (result (calendar-sync--split-events ics)))
+ (should (= 1 (length result)))
+ (should (string-match-p "SUMMARY:Test" (car result)))))
+
+(ert-deftest test-calendar-sync--split-events-normal-multiple ()
+ "Multiple VEVENTs return corresponding list."
+ (let* ((ics (concat "BEGIN:VCALENDAR\n"
+ "BEGIN:VEVENT\nSUMMARY:First\nEND:VEVENT\n"
+ "BEGIN:VEVENT\nSUMMARY:Second\nEND:VEVENT\n"
+ "END:VCALENDAR"))
+ (result (calendar-sync--split-events ics)))
+ (should (= 2 (length result)))
+ (should (string-match-p "First" (nth 0 result)))
+ (should (string-match-p "Second" (nth 1 result)))))
+
+;;; Boundary Cases
+
+(ert-deftest test-calendar-sync--split-events-boundary-empty-calendar ()
+ "Calendar with no VEVENTs returns empty list."
+ (let ((ics "BEGIN:VCALENDAR\nVERSION:2.0\nEND:VCALENDAR"))
+ (should (null (calendar-sync--split-events ics)))))
+
+(ert-deftest test-calendar-sync--split-events-boundary-preserves-content ()
+ "Each extracted block contains BEGIN:VEVENT through END:VEVENT."
+ (let* ((ics "BEGIN:VEVENT\nUID:abc\nSUMMARY:Test\nEND:VEVENT")
+ (result (calendar-sync--split-events ics)))
+ (should (string-prefix-p "BEGIN:VEVENT" (car result)))
+ (should (string-suffix-p "END:VEVENT" (car result)))))
+
+;;; Error Cases
+
+(ert-deftest test-calendar-sync--split-events-error-empty-string ()
+ "Empty string returns empty list."
+ (should (null (calendar-sync--split-events ""))))
+
+(provide 'test-calendar-sync--split-events)
+;;; test-calendar-sync--split-events.el ends here