diff options
| author | Craig Jennings <c@cjennings.net> | 2026-06-18 20:56:18 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-06-18 20:56:18 -0500 |
| commit | a8aa91a257796695d0fbbf471e90bd4ea74c70a8 (patch) | |
| tree | bb3bf51e5f0e0e95efad7feb39cb4606b99bdc13 /tests/test-ui-buffer-status-colors.el | |
| parent | 5cca052ceafd635ac6be54e3e1d90b55e3dc25aa (diff) | |
| download | dotemacs-a8aa91a257796695d0fbbf471e90bd4ea74c70a8.tar.gz dotemacs-a8aa91a257796695d0fbbf471e90bd4ea74c70a8.zip | |
refactor(ui): remove buffer-state coloring of the buffer name
The modeline colored the buffer name by write and modification state (red read-only, green modified, gold overwrite) through a classifier in user-constants.el. I removed it, the same way the matching cursor coloring was removed earlier for being more confusing than useful. The classifier had no other live user, so it and its two test files go with it. The buffer name now renders in the normal mode-line color.
Diffstat (limited to 'tests/test-ui-buffer-status-colors.el')
| -rw-r--r-- | tests/test-ui-buffer-status-colors.el | 98 |
1 files changed, 0 insertions, 98 deletions
diff --git a/tests/test-ui-buffer-status-colors.el b/tests/test-ui-buffer-status-colors.el deleted file mode 100644 index 06e466b85..000000000 --- a/tests/test-ui-buffer-status-colors.el +++ /dev/null @@ -1,98 +0,0 @@ -;;; test-ui-buffer-status-colors.el --- Tests for buffer-status faces -*- lexical-binding: t; -*- - -;;; Commentary: -;; The buffer-status state classifier (`cj/buffer-status-state'), the state->face -;; map (`cj/buffer-status-faces'), and the resolver (`cj/buffer-status-color') -;; drive both the cursor color and the modeline buffer-name color, kept in sync. -;; Theme faces (error / warning / success) replace the old hard-coded hexes so -;; the colors follow whatever theme is loaded. - -;;; Code: - -(require 'ert) -(require 'user-constants) -(require 'ui-config) -(require 'modeline-config) - -;;; State -> face map - -(ert-deftest test-buffer-status-faces-has-all-states () - "Normal: every buffer state is mapped to a face." - (dolist (state '(read-only overwrite modified unmodified)) - (should (alist-get state cj/buffer-status-faces)))) - -(ert-deftest test-buffer-status-faces-values-are-real-faces () - "Normal: every mapped value is an existing face." - (dolist (entry cj/buffer-status-faces) - (should (facep (cdr entry))))) - -(ert-deftest test-buffer-status-faces-mapping () - "Normal: read-only->error, overwrite/modified->warning, unmodified->success." - (should (eq (alist-get 'read-only cj/buffer-status-faces) 'error)) - (should (eq (alist-get 'overwrite cj/buffer-status-faces) 'warning)) - (should (eq (alist-get 'modified cj/buffer-status-faces) 'warning)) - (should (eq (alist-get 'unmodified cj/buffer-status-faces) 'success))) - -;;; State classifier (the shared function, exercised directly) - -(ert-deftest test-buffer-status-state-read-only () - "Normal: a read-only buffer reports `read-only'." - (with-temp-buffer - (setq buffer-read-only t) - (should (eq (cj/buffer-status-state) 'read-only)))) - -(ert-deftest test-buffer-status-state-overwrite-wins-over-modified () - "Boundary: overwrite-mode takes priority over the modified state." - (with-temp-buffer - (insert "x") - (overwrite-mode 1) - (should (eq (cj/buffer-status-state) 'overwrite)))) - -(ert-deftest test-buffer-status-state-modified () - "Normal: a writeable buffer with unsaved changes reports `modified'." - (with-temp-buffer - (insert "x") - (should (eq (cj/buffer-status-state) 'modified)))) - -(ert-deftest test-buffer-status-state-unmodified () - "Normal: a clean writeable buffer reports `unmodified'." - (with-temp-buffer - (set-buffer-modified-p nil) - (should (eq (cj/buffer-status-state) 'unmodified)))) - -(ert-deftest test-buffer-status-state-read-only-wins-over-modified () - "Boundary: read-only takes priority over modified." - (with-temp-buffer - (insert "x") - (set-buffer-modified-p t) - (setq buffer-read-only t) - (should (eq (cj/buffer-status-state) 'read-only)))) - -;;; Resolver - -(ert-deftest test-buffer-status-color-resolves-through-the-face () - "Normal: the color is the mapped face's foreground." - (let ((orig (face-attribute 'error :foreground nil t))) - (unwind-protect - (progn - (set-face-foreground 'error "#abcdef") - (should (equal (cj/buffer-status-color 'read-only) "#abcdef"))) - (when (stringp orig) (set-face-foreground 'error orig))))) - -(ert-deftest test-buffer-status-color-nil-for-unknown-state () - "Error: an unknown state has no face, so no color." - (should-not (cj/buffer-status-color 'nonexistent))) - -;;; Modeline integration - -(ert-deftest test-modeline-buffer-name-variable-exists () - "Normal: the modeline buffer-name construct is defined." - (should (boundp 'cj/modeline-buffer-name))) - -(ert-deftest test-modeline-buffer-name-is-mode-line-construct () - "Normal: it is an :eval mode-line construct." - (should (listp cj/modeline-buffer-name)) - (should (eq (car cj/modeline-buffer-name) :eval))) - -(provide 'test-ui-buffer-status-colors) -;;; test-ui-buffer-status-colors.el ends here |
