aboutsummaryrefslogtreecommitdiff
path: root/tests/test-nerd-icons-config--apply-tint.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-07 09:05:54 -0500
committerCraig Jennings <c@cjennings.net>2026-05-07 09:05:54 -0500
commit4ece1ebb4487d3e565642e45d586f97172fe97ce (patch)
tree5af6afbb683bcae92622b4c70922e5d6d27c6735 /tests/test-nerd-icons-config--apply-tint.el
parentb3ef232a486382601b6788f0c1a1edeb3982075d (diff)
downloaddotemacs-4ece1ebb4487d3e565642e45d586f97172fe97ce.tar.gz
dotemacs-4ece1ebb4487d3e565642e45d586f97172fe97ce.zip
fix: restore daemon icons and consolidate nerd-icons setup
I replaced the load-time icon-stub block in keyboard-compat with per-call :around advice that checks display-graphic-p against the rendering frame. The old block ran at module-load. Under daemon startup no frame exists yet, so display-graphic-p returned nil and the empty-string stubs installed permanently. Every GUI client connecting to that daemon then saw blanks. The new shape lets one daemon serve real icons to GUI clients and blanks to terminal clients. I also pulled the nerd-icons-completion and nerd-icons-ibuffer integrations, the package install, and a new tint helper into modules/nerd-icons-config.el. Per-feature use stays in the consuming module (dashboard, dirvish, keyboard-compat). The malformed cons-cell on the marginalia hook in selection-framework.el got fixed in the move. Added a default darkgoldenrod tint, a :filter-return advice on nerd-icons-icon-for-dir so dir icons pick up a color face, and a buffer-local face-remap in dired-mode-hook so plain files in dired render in shadow grey. 13 tests across 3 new files cover the per-call gate, the dir-color helper (idempotent under nerd-icons' memoized return strings), and the bulk-tint helper.
Diffstat (limited to 'tests/test-nerd-icons-config--apply-tint.el')
-rw-r--r--tests/test-nerd-icons-config--apply-tint.el63
1 files changed, 63 insertions, 0 deletions
diff --git a/tests/test-nerd-icons-config--apply-tint.el b/tests/test-nerd-icons-config--apply-tint.el
new file mode 100644
index 00000000..ef723352
--- /dev/null
+++ b/tests/test-nerd-icons-config--apply-tint.el
@@ -0,0 +1,63 @@
+;;; test-nerd-icons-config--apply-tint.el --- Tests for cj/nerd-icons-apply-tint -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Tests for the bulk-tint helper. Mocks `set-face-foreground' and `facep'
+;; at the framework boundary so the tests don't depend on nerd-icons being
+;; loaded — only on the symbol list and the dispatch logic.
+
+;;; Code:
+
+(require 'ert)
+(require 'cl-lib)
+
+(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
+(require 'nerd-icons-config)
+
+(defmacro test-nerd-icons-config--capture-set-face-foreground (calls-var &rest body)
+ "Run BODY with `set-face-foreground' and `facep' stubbed.
+Each (face color) pair gets pushed onto CALLS-VAR. `facep' returns t
+for every symbol so all faces in the list count as defined."
+ (declare (indent 1) (debug t))
+ `(cl-letf (((symbol-function 'set-face-foreground)
+ (lambda (face color &rest _) (push (cons face color) ,calls-var)))
+ ((symbol-function 'facep)
+ (lambda (_) t)))
+ ,@body))
+
+(ert-deftest test-nerd-icons-config--apply-tint-covers-every-face ()
+ "Normal: apply-tint calls set-face-foreground once per face in the list."
+ (let ((calls nil))
+ (test-nerd-icons-config--capture-set-face-foreground calls
+ (cj/nerd-icons-apply-tint "test-color"))
+ (should (= (length calls) (length cj/--nerd-icons-color-faces)))
+ (dolist (face cj/--nerd-icons-color-faces)
+ (should (assq face calls)))))
+
+(ert-deftest test-nerd-icons-config--apply-tint-passes-color-arg ()
+ "Normal: apply-tint forwards COLOR to every set-face-foreground call."
+ (let ((calls nil))
+ (test-nerd-icons-config--capture-set-face-foreground calls
+ (cj/nerd-icons-apply-tint "rebeccapurple"))
+ (dolist (call calls)
+ (should (equal (cdr call) "rebeccapurple")))))
+
+(ert-deftest test-nerd-icons-config--apply-tint-defaults-to-customvar ()
+ "Normal: with no COLOR arg, uses `cj/nerd-icons-tint-color'."
+ (let ((calls nil))
+ (test-nerd-icons-config--capture-set-face-foreground calls
+ (let ((cj/nerd-icons-tint-color "default-test-color"))
+ (cj/nerd-icons-apply-tint)))
+ (should (cl-every (lambda (call) (equal (cdr call) "default-test-color")) calls))))
+
+(ert-deftest test-nerd-icons-config--apply-tint-skips-undefined-faces ()
+ "Boundary: faces that fail `facep' are silently skipped, not errored."
+ (let ((calls nil))
+ (cl-letf (((symbol-function 'set-face-foreground)
+ (lambda (face color &rest _) (push (cons face color) calls)))
+ ((symbol-function 'facep)
+ (lambda (_) nil)))
+ (cj/nerd-icons-apply-tint "any"))
+ (should (null calls))))
+
+(provide 'test-nerd-icons-config--apply-tint)
+;;; test-nerd-icons-config--apply-tint.el ends here