summaryrefslogtreecommitdiff
path: root/tests/test-calendar-sync--extract-cn.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-04-05 07:04:37 -0500
committerCraig Jennings <c@cjennings.net>2026-04-05 07:04:37 -0500
commit4fa136a0f8bfde7852655a9fce2c44422bd32b3a (patch)
tree5e5029e640cc003c58a022471a9c631fd628d2bf /tests/test-calendar-sync--extract-cn.el
parent10e2929d5be68ec1fda8b5b4ed08511eac02e7b3 (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--extract-cn.el')
-rw-r--r--tests/test-calendar-sync--extract-cn.el48
1 files changed, 48 insertions, 0 deletions
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