;;; test-pearl-mapping.el --- Tests for pearl mapping helpers -*- 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: ;; Unit tests for the pure mapping helpers in pearl.el: ;; Linear priority -> org cookie / readable name, and the priority list. ;;; Code: (require 'test-bootstrap (expand-file-name "test-bootstrap.el")) ;; The static Linear-state -> Org-keyword mapping and its derived regex were ;; removed once keyword rendering moved to slugifying the state name ;; (`pearl--state-name-to-keyword'), and the keyword -> state-id direction moved ;; to resolving through the team's states (`pearl--resolve-keyword-to-state'). ;; What remains pure-mapping-shaped is the priority conversion, tested below. ;;; pearl--map-linear-priority-to-org (ert-deftest test-pearl-map-linear-priority-to-org-known-values () "Linear priorities 1-4 map to org cookies A-D." (should (string-equal "[#A]" (pearl--map-linear-priority-to-org 1))) (should (string-equal "[#B]" (pearl--map-linear-priority-to-org 2))) (should (string-equal "[#C]" (pearl--map-linear-priority-to-org 3))) (should (string-equal "[#D]" (pearl--map-linear-priority-to-org 4)))) (ert-deftest test-pearl-map-linear-priority-to-org-none-no-cookie () "Priority 0 (No priority) maps to no cookie, distinct from Medium's [#C]." (should (string-equal "" (pearl--map-linear-priority-to-org 0)))) (ert-deftest test-pearl-map-linear-priority-to-org-nil-and-unknown-no-cookie () "A nil or out-of-range priority maps to no cookie." (should (string-equal "" (pearl--map-linear-priority-to-org nil))) (should (string-equal "" (pearl--map-linear-priority-to-org 99)))) ;;; pearl--get-linear-priority-name (ert-deftest test-pearl-get-linear-priority-name-known-values () "Linear priorities 1-4 have readable names." (should (string-equal "Urgent" (pearl--get-linear-priority-name 1))) (should (string-equal "High" (pearl--get-linear-priority-name 2))) (should (string-equal "Medium" (pearl--get-linear-priority-name 3))) (should (string-equal "Low" (pearl--get-linear-priority-name 4)))) (ert-deftest test-pearl-get-linear-priority-name-none-and-unknown () "Zero (None), nil, and out-of-range priorities read as None." (should (string-equal "None" (pearl--get-linear-priority-name 0))) (should (string-equal "None" (pearl--get-linear-priority-name nil))) (should (string-equal "None" (pearl--get-linear-priority-name 99)))) ;;; pearl-get-priorities (ert-deftest test-pearl-get-priorities-returns-fixed-alist () "The priority list maps the five Linear priority names to their integers." (let ((priorities (pearl-get-priorities))) (should (equal 0 (cdr (assoc "No priority" priorities)))) (should (equal 1 (cdr (assoc "Urgent" priorities)))) (should (equal 2 (cdr (assoc "High" priorities)))) (should (equal 3 (cdr (assoc "Medium" priorities)))) (should (equal 4 (cdr (assoc "Low" priorities)))))) (provide 'test-pearl-mapping) ;;; test-pearl-mapping.el ends here