diff options
Diffstat (limited to 'tests/test-chime-has-timestamp.el')
| -rw-r--r-- | tests/test-chime-has-timestamp.el | 278 |
1 files changed, 105 insertions, 173 deletions
diff --git a/tests/test-chime-has-timestamp.el b/tests/test-chime-has-timestamp.el index 1c79fb7..3e946ab 100644 --- a/tests/test-chime-has-timestamp.el +++ b/tests/test-chime-has-timestamp.el @@ -26,239 +26,171 @@ (require 'test-bootstrap (expand-file-name "test-bootstrap.el")) -;; Load test utilities -(require 'testutil-general (expand-file-name "testutil-general.el")) -(require 'testutil-time (expand-file-name "testutil-time.el")) - -;;; Setup and Teardown - -(defun test-chime-has-timestamp-setup () - "Setup function run before each test." - (chime-create-test-base-dir)) - -(defun test-chime-has-timestamp-teardown () - "Teardown function run after each test." - (chime-delete-test-base-dir)) - ;;; Normal Cases -(ert-deftest test-chime-has-timestamp-standard-timestamp-with-time-returns-non-nil () +(chime-deftest test-chime-has-timestamp-standard-timestamp-with-time-returns-non-nil () "Test that standard timestamp with time returns non-nil. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 14 30)) - (timestamp (test-timestamp-string time)) - (result (chime--has-timestamp timestamp))) - (should result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-timestamp-without-brackets-returns-non-nil () + (let* ((time (test-time-tomorrow-at 14 30)) + (timestamp (test-timestamp-string time)) + (result (chime--has-timestamp timestamp))) + (should result))) + +(chime-deftest test-chime-has-timestamp-timestamp-without-brackets-returns-non-nil () "Test that timestamp without brackets but with time returns non-nil. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 14 30)) - (timestamp (format-time-string "%Y-%m-%d %a %H:%M" time)) - (result (chime--has-timestamp timestamp))) - (should result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-timestamp-with-time-range-returns-non-nil () + (let* ((time (test-time-tomorrow-at 14 30)) + (timestamp (format-time-string "%Y-%m-%d %a %H:%M" time)) + (result (chime--has-timestamp timestamp))) + (should result))) + +(chime-deftest test-chime-has-timestamp-timestamp-with-time-range-returns-non-nil () "Test that timestamp with time range returns non-nil. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 14 0)) - (timestamp (format-time-string "<%Y-%m-%d %a %H:%M-15:30>" time)) - (result (chime--has-timestamp timestamp))) - (should result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-scheduled-with-time-returns-non-nil () + (let* ((time (test-time-tomorrow-at 14 0)) + (timestamp (format-time-string "<%Y-%m-%d %a %H:%M-15:30>" time)) + (result (chime--has-timestamp timestamp))) + (should result))) + +(chime-deftest test-chime-has-timestamp-scheduled-with-time-returns-non-nil () "Test that SCHEDULED timestamp with time returns non-nil. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 9 0)) - (timestamp (concat "SCHEDULED: " (test-timestamp-string time))) - (result (chime--has-timestamp timestamp))) - (should result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-deadline-with-time-returns-non-nil () + (let* ((time (test-time-tomorrow-at 9 0)) + (timestamp (concat "SCHEDULED: " (test-timestamp-string time))) + (result (chime--has-timestamp timestamp))) + (should result))) + +(chime-deftest test-chime-has-timestamp-deadline-with-time-returns-non-nil () "Test that DEADLINE timestamp with time returns non-nil. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 17 0)) - (timestamp (concat "DEADLINE: " (test-timestamp-string time))) - (result (chime--has-timestamp timestamp))) - (should result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-repeater-with-time-returns-non-nil () + (let* ((time (test-time-tomorrow-at 17 0)) + (timestamp (concat "DEADLINE: " (test-timestamp-string time))) + (result (chime--has-timestamp timestamp))) + (should result))) + +(chime-deftest test-chime-has-timestamp-repeater-with-time-returns-non-nil () "Test that timestamp with repeater and time returns non-nil. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 14 0)) - (timestamp (format-time-string "<%Y-%m-%d %a %H:%M +1w>" time)) - (result (chime--has-timestamp timestamp))) - (should result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-midnight-timestamp-returns-non-nil () + (let* ((time (test-time-tomorrow-at 14 0)) + (timestamp (format-time-string "<%Y-%m-%d %a %H:%M +1w>" time)) + (result (chime--has-timestamp timestamp))) + (should result))) + +(chime-deftest test-chime-has-timestamp-midnight-timestamp-returns-non-nil () "Test that midnight timestamp (00:00) returns non-nil. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 0 0)) - (timestamp (test-timestamp-string time)) - (result (chime--has-timestamp timestamp))) - (should result)) - (test-chime-has-timestamp-teardown))) + (let* ((time (test-time-tomorrow-at 0 0)) + (timestamp (test-timestamp-string time)) + (result (chime--has-timestamp timestamp))) + (should result))) ;;; Boundary Cases -(ert-deftest test-chime-has-timestamp-day-wide-timestamp-returns-nil () +(chime-deftest test-chime-has-timestamp-day-wide-timestamp-returns-nil () "Test that day-wide timestamp without time returns nil. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 0 0)) - (timestamp (test-timestamp-string time t)) - (result (chime--has-timestamp timestamp))) - (should-not result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-date-only-returns-nil () + (let* ((time (test-time-tomorrow-at 0 0)) + (timestamp (test-timestamp-string time t)) + (result (chime--has-timestamp timestamp))) + (should-not result))) + +(chime-deftest test-chime-has-timestamp-date-only-returns-nil () "Test that date-only timestamp without day name returns nil. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 0 0)) - (timestamp (format-time-string "<%Y-%m-%d>" time)) - (result (chime--has-timestamp timestamp))) - (should-not result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-single-digit-hour-returns-non-nil () + (let* ((time (test-time-tomorrow-at 0 0)) + (timestamp (format-time-string "<%Y-%m-%d>" time)) + (result (chime--has-timestamp timestamp))) + (should-not result))) + +(chime-deftest test-chime-has-timestamp-single-digit-hour-returns-non-nil () "Test that timestamp with single-digit hour returns non-nil. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 9 0)) - (timestamp (format-time-string "<%Y-%m-%d %a %-H:%M>" time)) - (result (chime--has-timestamp timestamp))) - (should result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-embedded-in-text-returns-non-nil () + (let* ((time (test-time-tomorrow-at 9 0)) + (timestamp (format-time-string "<%Y-%m-%d %a %-H:%M>" time)) + (result (chime--has-timestamp timestamp))) + (should result))) + +(chime-deftest test-chime-has-timestamp-embedded-in-text-returns-non-nil () "Test that timestamp embedded in text returns non-nil. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 14 0)) - (timestamp (concat "Meeting scheduled for " (test-timestamp-string time) " in conference room")) - (result (chime--has-timestamp timestamp))) - (should result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-multiple-timestamps-returns-non-nil () + (let* ((time (test-time-tomorrow-at 14 0)) + (timestamp (concat "Meeting scheduled for " (test-timestamp-string time) " in conference room")) + (result (chime--has-timestamp timestamp))) + (should result))) + +(chime-deftest test-chime-has-timestamp-multiple-timestamps-returns-non-nil () "Test that string with multiple timestamps returns non-nil for first match. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time1 (test-time-tomorrow-at 14 0)) - (time2 (test-time-days-from-now 2)) - (timestamp (concat (test-timestamp-string time1) " and " - (format-time-string "<%Y-%m-%d %a %H:%M>" time2))) - (result (chime--has-timestamp timestamp))) - (should result)) - (test-chime-has-timestamp-teardown))) + (let* ((time1 (test-time-tomorrow-at 14 0)) + (time2 (test-time-days-from-now 2)) + (timestamp (concat (test-timestamp-string time1) " and " + (format-time-string "<%Y-%m-%d %a %H:%M>" time2))) + (result (chime--has-timestamp timestamp))) + (should result))) ;;; Error Cases -(ert-deftest test-chime-has-timestamp-empty-string-returns-nil () +(chime-deftest test-chime-has-timestamp-empty-string-returns-nil () "Test that empty string returns nil." - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((timestamp "") - (result (chime--has-timestamp timestamp))) - (should-not result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-nil-input-returns-nil () + (let* ((timestamp "") + (result (chime--has-timestamp timestamp))) + (should-not result))) + +(chime-deftest test-chime-has-timestamp-nil-input-returns-nil () "Test that nil input returns nil." - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((timestamp nil) - (result (chime--has-timestamp timestamp))) - (should-not result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-no-timestamp-returns-nil () + (let* ((timestamp nil) + (result (chime--has-timestamp timestamp))) + (should-not result))) + +(chime-deftest test-chime-has-timestamp-no-timestamp-returns-nil () "Test that string without timestamp returns nil." - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((timestamp "Just a regular string with no timestamp") - (result (chime--has-timestamp timestamp))) - (should-not result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-invalid-format-returns-nil () + (let* ((timestamp "Just a regular string with no timestamp") + (result (chime--has-timestamp timestamp))) + (should-not result))) + +(chime-deftest test-chime-has-timestamp-invalid-format-returns-nil () "Test that invalid timestamp format returns nil. REFACTORED: Uses dynamic timestamps (keeps invalid format for testing)" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 14 0)) - ;; Intentionally wrong format (MM-DD-YYYY instead of YYYY-MM-DD) for testing - (timestamp (format-time-string "<%m-%d-%Y %a %H:%M>" time)) - (result (chime--has-timestamp timestamp))) - (should-not result)) - (test-chime-has-timestamp-teardown))) - -(ert-deftest test-chime-has-timestamp-partial-timestamp-returns-nil () + (let* ((time (test-time-tomorrow-at 14 0)) + ;; Intentionally wrong format (MM-DD-YYYY instead of YYYY-MM-DD) for testing + (timestamp (format-time-string "<%m-%d-%Y %a %H:%M>" time)) + (result (chime--has-timestamp timestamp))) + (should-not result))) + +(chime-deftest test-chime-has-timestamp-partial-timestamp-returns-nil () "Test that partial timestamp returns nil. REFACTORED: Uses dynamic timestamps (keeps partial format for testing)" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 0 0)) - ;; Intentionally incomplete timestamp for testing - (timestamp (format-time-string "<%Y-%m-%d" time)) - (result (chime--has-timestamp timestamp))) - (should-not result)) - (test-chime-has-timestamp-teardown))) + (let* ((time (test-time-tomorrow-at 0 0)) + ;; Intentionally incomplete timestamp for testing + (timestamp (format-time-string "<%Y-%m-%d" time)) + (result (chime--has-timestamp timestamp))) + (should-not result))) ;;; org-gcal Integration Tests -(ert-deftest test-chime-has-timestamp-org-gcal-time-range-returns-non-nil () +(chime-deftest test-chime-has-timestamp-org-gcal-time-range-returns-non-nil () "Test that org-gcal time range format is detected. org-gcal uses format like <2025-10-24 Fri 17:30-18:00> which should be detected. REFACTORED: Uses dynamic timestamps" - (test-chime-has-timestamp-setup) - (unwind-protect - (let* ((time (test-time-tomorrow-at 17 30)) - (timestamp (format-time-string "<%Y-%m-%d %a %H:%M-18:00>" time)) - (result (chime--has-timestamp timestamp))) - (should result)) - (test-chime-has-timestamp-teardown))) + (let* ((time (test-time-tomorrow-at 17 30)) + (timestamp (format-time-string "<%Y-%m-%d %a %H:%M-18:00>" time)) + (result (chime--has-timestamp timestamp))) + (should result))) (provide 'test-chime-has-timestamp) ;;; test-chime-has-timestamp.el ends here |
