Skip to content

Commit 9668724

Browse files
committed
Add ERT test for ghostel-sync-theme
Verify that theme sync applies the palette to ghostel-mode buffers, triggers a redraw, and skips the redraw when copy mode is active.
1 parent eb545fa commit 9668724

1 file changed

Lines changed: 38 additions & 1 deletion

File tree

test/ghostel-test.el

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,42 @@
783783
(should-not (string-match-p "new prompt>" content))))) ; mid-BSU: no prompt
784784
(kill-buffer buf))))
785785

786+
;; -----------------------------------------------------------------------
787+
;; Test: theme synchronization
788+
;; -----------------------------------------------------------------------
789+
790+
(ert-deftest ghostel-test-sync-theme ()
791+
"Test that ghostel-sync-theme applies palette and redraws ghostel buffers."
792+
(let ((palette-calls nil)
793+
(redraw-calls nil))
794+
(cl-letf (((symbol-function 'ghostel--apply-palette)
795+
(lambda (term) (push term palette-calls)))
796+
((symbol-function 'ghostel--redraw)
797+
(lambda (term) (push term redraw-calls))))
798+
(let ((buf (generate-new-buffer " *ghostel-test-theme*"))
799+
(other (generate-new-buffer " *ghostel-test-other*")))
800+
(unwind-protect
801+
(progn
802+
;; Set up a ghostel-mode buffer with a fake terminal
803+
(with-current-buffer buf
804+
(ghostel-mode)
805+
(setq ghostel--term 'fake-term)
806+
(setq ghostel--copy-mode-active nil))
807+
;; other buffer is not ghostel-mode
808+
(ghostel-sync-theme)
809+
(should (memq 'fake-term palette-calls)) ; palette applied to ghostel buffer
810+
(should (memq 'fake-term redraw-calls)) ; redraw called for ghostel buffer
811+
812+
;; Verify copy-mode skips redraw
813+
(setq palette-calls nil redraw-calls nil)
814+
(with-current-buffer buf
815+
(setq ghostel--copy-mode-active t))
816+
(ghostel-sync-theme)
817+
(should (memq 'fake-term palette-calls)) ; palette still applied in copy mode
818+
(should-not (memq 'fake-term redraw-calls))) ; redraw skipped in copy mode
819+
(kill-buffer buf)
820+
(kill-buffer other))))))
821+
786822
;; -----------------------------------------------------------------------
787823
;; Runner
788824
;; -----------------------------------------------------------------------
@@ -794,7 +830,8 @@
794830
ghostel-test-raw-key-modified-specials
795831
ghostel-test-update-directory
796832
ghostel-test-filter-soft-wraps
797-
ghostel-test-prompt-navigation)
833+
ghostel-test-prompt-navigation
834+
ghostel-test-sync-theme)
798835
"Tests that require only Elisp (no native module).")
799836

800837
(defun ghostel-test-run-elisp ()

0 commit comments

Comments
 (0)