From 4fa136a0f8bfde7852655a9fce2c44422bd32b3a Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Sun, 5 Apr 2026 07:04:37 -0500 Subject: 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). --- tests/test-calendar-sync--extract-cn.el | 48 +++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/test-calendar-sync--extract-cn.el (limited to 'tests/test-calendar-sync--extract-cn.el') diff --git a/tests/test-calendar-sync--extract-cn.el b/tests/test-calendar-sync--extract-cn.el new file mode 100644 index 00000000..0cb8f80c --- /dev/null +++ b/tests/test-calendar-sync--extract-cn.el @@ -0,0 +1,48 @@ +;;; test-calendar-sync--extract-cn.el --- Tests for CN parameter extraction -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for calendar-sync--extract-cn. +;; Extracts and dequotes the CN= parameter from iCal property lines. + +;;; Code: + +(require 'ert) +(require 'testutil-calendar-sync) +(require 'calendar-sync) + +;;; Normal Cases + +(ert-deftest test-calendar-sync--extract-cn-normal-unquoted () + "Extracts unquoted CN value." + (should (equal "Craig Jennings" + (calendar-sync--extract-cn + "ATTENDEE;CN=Craig Jennings;PARTSTAT=ACCEPTED:mailto:c@test.com")))) + +(ert-deftest test-calendar-sync--extract-cn-normal-quoted () + "Strips surrounding quotes from CN value." + (should (equal "Craig Jennings" + (calendar-sync--extract-cn + "ATTENDEE;CN=\"Craig Jennings\";PARTSTAT=ACCEPTED:mailto:c@test.com")))) + +;;; Boundary Cases + +(ert-deftest test-calendar-sync--extract-cn-boundary-cn-at-end () + "CN as last parameter before colon." + (should (equal "Bob" + (calendar-sync--extract-cn "ORGANIZER;CN=Bob:mailto:bob@test.com")))) + +(ert-deftest test-calendar-sync--extract-cn-boundary-special-chars () + "CN with accented characters." + (should (equal "José García" + (calendar-sync--extract-cn + "ATTENDEE;CN=José García;PARTSTAT=ACCEPTED:mailto:j@test.com")))) + +;;; Error Cases + +(ert-deftest test-calendar-sync--extract-cn-error-no-cn () + "Line without CN= returns nil." + (should (null (calendar-sync--extract-cn + "ATTENDEE;PARTSTAT=ACCEPTED:mailto:c@test.com")))) + +(provide 'test-calendar-sync--extract-cn) +;;; test-calendar-sync--extract-cn.el ends here -- cgit v1.2.3