;;; test-pearl-todo-keywords.el --- Tests for deriving TODO keywords from states -*- lexical-binding: t; -*- ;; Copyright (C) 2026 Craig Jennings ;; Author: Craig Jennings ;; This program is free software: you can redistribute it and/or modify ;; it under the terms of the GNU General Public License as published by ;; the Free Software Foundation, either version 3 of the License, or ;; (at your option) any later version. ;; This program is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; GNU General Public License for more details. ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . ;;; Commentary: ;; Tests for the pure derivation helpers behind the workspace-derived #+TODO ;; line: `pearl--state-name-to-keyword' (slugify a Linear state name to an Org ;; keyword) and `pearl--derive-todo-line' (an ordered state list to the ;; "ACTIVE... | DONE..." keyword string). ;;; Code: (require 'test-bootstrap (expand-file-name "test-bootstrap.el")) ;;; --state-name-to-keyword (slugify) (ert-deftest test-pearl-state-name-to-keyword-spaces-and-case () "Spaces become hyphens and the name is upcased." (should (string= "DEV-REVIEW" (pearl--state-name-to-keyword "Dev Review"))) (should (string= "IN-PROGRESS" (pearl--state-name-to-keyword "In Progress"))) (should (string= "TODO" (pearl--state-name-to-keyword "Todo")))) (ert-deftest test-pearl-state-name-to-keyword-punctuation-runs () "A run of non-alphanumerics collapses to a single hyphen; edges trimmed." (should (string= "PM-ACCEPTANCE" (pearl--state-name-to-keyword "PM Acceptance"))) (should (string= "BACKLOG-PRIORITIZED" (pearl--state-name-to-keyword "Backlog (prioritized)")))) (ert-deftest test-pearl-state-name-to-keyword-unicode-preserved () "Unicode letters are kept (alnum is Unicode-aware), not stripped." (should (string= "ÅNGSTRÖM" (pearl--state-name-to-keyword "Ångström")))) (ert-deftest test-pearl-state-name-to-keyword-empty-slug-falls-back () "An all-symbol name (empty slug) falls back to TODO, as does the empty string." (should (string= "TODO" (pearl--state-name-to-keyword "!!!"))) (should (string= "TODO" (pearl--state-name-to-keyword "")))) ;;; --derive-todo-line (ert-deftest test-pearl-derive-todo-line-partitions-by-type () "Completed/canceled/duplicate states go after the bar; the rest before it." (should (string= "TODO IN-PROGRESS | DONE CANCELED" (pearl--derive-todo-line '((:name "Todo" :type "unstarted") (:name "In Progress" :type "started") (:name "Done" :type "completed") (:name "Canceled" :type "canceled")))))) (ert-deftest test-pearl-derive-todo-line-dedups-by-slug () "Two names slugifying to the same keyword list it once (first-seen)." (should (string= "DEV-REVIEW |" (pearl--derive-todo-line '((:name "Dev Review" :type "started") (:name "Dev-Review" :type "started")))))) (ert-deftest test-pearl-derive-todo-line-preserves-input-order () "Within each side, the caller's order is preserved." (should (string= "BACKLOG TODO IN-PROGRESS | DONE" (pearl--derive-todo-line '((:name "Backlog" :type "backlog") (:name "Todo" :type "unstarted") (:name "In Progress" :type "started") (:name "Done" :type "completed")))))) (ert-deftest test-pearl-derive-todo-line-empty-is-hardcoded-fallback () "An empty state list yields the hardcoded default so the file stays valid." (should (string= "TODO IN-PROGRESS IN-REVIEW BACKLOG BLOCKED | DONE" (pearl--derive-todo-line '())))) (provide 'test-pearl-todo-keywords) ;;; test-pearl-todo-keywords.el ends here