From 28b7e4cecadce207d532b8d42346c3823450a35f Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 17 Feb 2026 19:14:14 -0600 Subject: refactor: tests: standardize naming, consolidate files, and expand testutil - Expand testutil-wttrin.el with shared fixtures and macros (testutil-wttrin-with-clean-weather-buffer, testutil-wttrin-mock-http-response, sample ANSI/weather constants) - Consolidate cache tests: port unique tests from cleanup-cache-constants and cleanup-cache-refactored into cleanup-cache-if-needed, delete obsolete files - Extract startup-delay tests into dedicated file - Add setup/teardown and (require 'testutil-wttrin) to all test files - Rename all 160 tests to follow test---- convention - Rename integration test file and add detailed docstrings - Update Makefile glob to discover new integration test naming pattern Co-Authored-By: Claude Opus 4.6 --- tests/test-wttrin--mode-line-map.el | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'tests/test-wttrin--mode-line-map.el') diff --git a/tests/test-wttrin--mode-line-map.el b/tests/test-wttrin--mode-line-map.el index 7a1052e..2328300 100644 --- a/tests/test-wttrin--mode-line-map.el +++ b/tests/test-wttrin--mode-line-map.el @@ -10,43 +10,54 @@ (require 'ert) (require 'wttrin) +(require 'testutil-wttrin) + +;;; Setup and Teardown + +(defun test-wttrin--mode-line-map-setup () + "Setup for mode-line-map tests." + (testutil-wttrin-setup)) + +(defun test-wttrin--mode-line-map-teardown () + "Teardown for mode-line-map tests." + (testutil-wttrin-teardown)) ;;; Normal Cases - Keymap Existence and Structure -(ert-deftest test-wttrin--mode-line-map-exists () +(ert-deftest test-wttrin--mode-line-map-normal-defvar-exists-returns-true () "Test that wttrin--mode-line-map defvar exists after refactoring." (should (boundp 'wttrin--mode-line-map))) -(ert-deftest test-wttrin--mode-line-map-is-keymap () +(ert-deftest test-wttrin--mode-line-map-normal-value-is-keymap-returns-true () "Test that wttrin--mode-line-map is actually a keymap." (should (keymapp wttrin--mode-line-map))) -(ert-deftest test-wttrin--mode-line-map-is-sparse-keymap () +(ert-deftest test-wttrin--mode-line-map-normal-structure-is-sparse-keymap () "Test that wttrin--mode-line-map is a sparse keymap." ;; Sparse keymaps start with 'keymap symbol (should (eq 'keymap (car wttrin--mode-line-map)))) ;;; Keybinding Tests -(ert-deftest test-wttrin--mode-line-map-has-mouse-1-binding () +(ert-deftest test-wttrin--mode-line-map-normal-mouse-1-bound-to-click () "Test that left-click (mouse-1) is bound to wttrin-mode-line-click." (let ((binding (lookup-key wttrin--mode-line-map [mode-line mouse-1]))) (should (eq binding 'wttrin-mode-line-click)))) -(ert-deftest test-wttrin--mode-line-map-has-mouse-3-binding () +(ert-deftest test-wttrin--mode-line-map-normal-mouse-3-bound-to-force-refresh () "Test that right-click (mouse-3) is bound to wttrin-mode-line-force-refresh." (let ((binding (lookup-key wttrin--mode-line-map [mode-line mouse-3]))) (should (eq binding 'wttrin-mode-line-force-refresh)))) ;;; Boundary Cases - Verify No Unexpected Bindings -(ert-deftest test-wttrin--mode-line-map-no-mouse-2-binding () +(ert-deftest test-wttrin--mode-line-map-boundary-mouse-2-has-no-binding () "Test that middle-click (mouse-2) has no binding." (let ((binding (lookup-key wttrin--mode-line-map [mode-line mouse-2]))) ;; Should return nil (unbound) or a prefix keymap (should-not (and binding (symbolp binding))))) -(ert-deftest test-wttrin--mode-line-map-minimal-bindings () +(ert-deftest test-wttrin--mode-line-map-boundary-keymap-has-expected-binding-count () "Test that keymap has the expected bindings." ;; Count non-nil entries in keymap (let ((count 0)) @@ -60,7 +71,7 @@ ;;; Integration Test - Verify Mode-Line Uses the Keymap -(ert-deftest test-wttrin-mode-line-display-uses-shared-keymap () +(ert-deftest test-wttrin--mode-line-map-normal-display-uses-shared-keymap () "Test that mode-line display uses wttrin--mode-line-map after refactoring. This test verifies the refactoring eliminated inline keymap construction." ;; Set up minimal mode-line state -- cgit v1.2.3