diff options
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-ui-config--buffer-cursor-state.el | 7 | ||||
| -rw-r--r-- | tests/test-ui-cursor-color-integration.el | 11 |
2 files changed, 16 insertions, 2 deletions
diff --git a/tests/test-ui-config--buffer-cursor-state.el b/tests/test-ui-config--buffer-cursor-state.el index add0d030..ead05741 100644 --- a/tests/test-ui-config--buffer-cursor-state.el +++ b/tests/test-ui-config--buffer-cursor-state.el @@ -72,7 +72,9 @@ buffer the user navigates, so `read-only' (orange) is kept." (ert-deftest test-ui-config-set-cursor-color-live-vterm-not-orange () "Normal: in a live vterm the cursor-color hook picks a writeable color, -not the read-only orange -- even though the vterm buffer is read-only." +not the read-only orange -- even though the vterm buffer is read-only. +`display-graphic-p' is stubbed t so the function reaches its work body +in batch mode (the live function no-ops on TTY frames by design)." (let ((buf (cj/test--make-fake-vterm-buffer "*test-vterm-cursor-color*")) (applied 'unset)) (unwind-protect @@ -81,7 +83,8 @@ not the read-only orange -- even though the vterm buffer is read-only." (setq-local vterm-copy-mode nil) (let ((cj/-cursor-last-color nil) (cj/-cursor-last-buffer nil)) - (cl-letf (((symbol-function 'set-cursor-color) + (cl-letf (((symbol-function 'display-graphic-p) (lambda () t)) + ((symbol-function 'set-cursor-color) (lambda (c) (setq applied c)))) (cj/set-cursor-color-according-to-mode))) (should (stringp applied)) diff --git a/tests/test-ui-cursor-color-integration.el b/tests/test-ui-cursor-color-integration.el index 00b7f57b..c28bde92 100644 --- a/tests/test-ui-cursor-color-integration.el +++ b/tests/test-ui-cursor-color-integration.el @@ -9,6 +9,17 @@ (require 'ert) (require 'user-constants) + +;; `cj/set-cursor-color-according-to-mode' and the `post-command-hook' +;; install both gate on `display-graphic-p' -- a TTY / batch run is a +;; no-op for cursor coloring by design. These integration tests +;; exercise the work body, so we pretend we're in a graphical session +;; for the whole file. Stubbing the symbol BEFORE loading ui-config +;; matters because the hook install reads `display-graphic-p' at load +;; time. +(advice-add 'display-graphic-p :around + (lambda (orig &rest args) (or (apply orig args) t))) + (require 'ui-config) ;;; Hook Integration Tests |
