From 7eb6c0692d48b8c3d01efba8abcd2bfdfaa7cd31 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 5 Apr 2026 06:51:20 -0500 Subject: 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). --- tests/test-calendar-sync--split-events.el | 54 +++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 tests/test-calendar-sync--split-events.el (limited to 'tests/test-calendar-sync--split-events.el') 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 -- cgit v1.2.3