aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-modeline-config-string-cut-middle.el8
-rw-r--r--tests/test-modeline-config-string-truncate-p.el8
-rw-r--r--tests/test-ui-buffer-status-colors.el98
-rw-r--r--tests/test-ui-config--buffer-cursor-state.el74
4 files changed, 0 insertions, 188 deletions
diff --git a/tests/test-modeline-config-string-cut-middle.el b/tests/test-modeline-config-string-cut-middle.el
index 40cc0bccc..d68431b49 100644
--- a/tests/test-modeline-config-string-cut-middle.el
+++ b/tests/test-modeline-config-string-cut-middle.el
@@ -17,14 +17,6 @@
;; Add modules directory to load path
(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
-;; Stub dependencies before loading the module
-(unless (boundp 'cj/buffer-status-colors)
- (defvar cj/buffer-status-colors
- '((unmodified . "#FFFFFF")
- (modified . "#00FF00")
- (read-only . "#FF0000")
- (overwrite . "#FFD700"))))
-
(require 'modeline-config)
;;; Test Helpers
diff --git a/tests/test-modeline-config-string-truncate-p.el b/tests/test-modeline-config-string-truncate-p.el
index 09378b0d1..94ea74171 100644
--- a/tests/test-modeline-config-string-truncate-p.el
+++ b/tests/test-modeline-config-string-truncate-p.el
@@ -19,14 +19,6 @@
;; Add modules directory to load path
(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
-;; Stub dependencies before loading the module
-(unless (boundp 'cj/buffer-status-colors)
- (defvar cj/buffer-status-colors
- '((unmodified . "#FFFFFF")
- (modified . "#00FF00")
- (read-only . "#FF0000")
- (overwrite . "#FFD700"))))
-
(require 'modeline-config)
;;; Test Helpers
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
diff --git a/tests/test-ui-config--buffer-cursor-state.el b/tests/test-ui-config--buffer-cursor-state.el
deleted file mode 100644
index 99cfc4b9d..000000000
--- a/tests/test-ui-config--buffer-cursor-state.el
+++ /dev/null
@@ -1,74 +0,0 @@
-;;; test-ui-config--buffer-cursor-state.el --- Tests for cursor-state classification -*- lexical-binding: t; -*-
-
-;;; Commentary:
-;; `cj/buffer-status-state' picks the buffer-state symbol the modeline
-;; buffer-name indicator maps to a face via `cj/buffer-status-color'. The
-;; subtle case: a live ghostel terminal is
-;; technically `buffer-read-only' but the user types into it -- keystrokes go
-;; to the terminal process -- so it must report a writeable state, not
-;; `read-only'. ghostel's `copy' / `emacs' input modes are the exception:
-;; there the buffer really is a read-only Emacs buffer the user navigates, so
-;; `read-only' (the orange cursor) is correct and kept.
-
-;;; Code:
-
-(require 'ert)
-(require 'cl-lib)
-
-(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
-(add-to-list 'load-path (expand-file-name "tests" user-emacs-directory))
-(setq load-prefer-newer t)
-(defvar ghostel--input-mode nil)
-(require 'ui-config)
-(require 'testutil-ghostel-buffers)
-
-(ert-deftest test-ui-config-buffer-cursor-state-readwrite-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-ui-config-buffer-cursor-state-readwrite-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-ui-config-buffer-cursor-state-read-only ()
- "Normal: a plain 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-ui-config-buffer-cursor-state-overwrite ()
- "Boundary: `overwrite-mode' wins over the modified/unmodified split."
- (with-temp-buffer
- (insert "x")
- (overwrite-mode 1)
- (should (eq (cj/buffer-status-state) 'overwrite))))
-
-(ert-deftest test-ui-config-buffer-cursor-state-live-ghostel-is-writeable ()
- "Boundary: a live ghostel buffer is `buffer-read-only' but reports a
-writeable state -- the user types into the terminal process there, so the
-read-only (orange) cursor would be misleading."
- (let ((buf (cj/test--make-fake-ghostel-buffer "*test-ghostel-cursor-state*")))
- (unwind-protect
- (with-current-buffer buf
- (setq buffer-read-only t) ; ghostel keeps the buffer read-only
- (setq-local ghostel--input-mode 'semi-char)
- (should-not (eq (cj/buffer-status-state) 'read-only)))
- (when (buffer-live-p buf) (kill-buffer buf)))))
-
-(ert-deftest test-ui-config-buffer-cursor-state-ghostel-copy-mode-is-read-only ()
- "Boundary: in ghostel `copy' mode the buffer is a read-only Emacs buffer
-the user navigates, so `read-only' (orange) is kept."
- (let ((buf (cj/test--make-fake-ghostel-buffer "*test-ghostel-cursor-state-copy*")))
- (unwind-protect
- (with-current-buffer buf
- (setq buffer-read-only t)
- (setq-local ghostel--input-mode 'copy)
- (should (eq (cj/buffer-status-state) 'read-only)))
- (when (buffer-live-p buf) (kill-buffer buf)))))
-
-(provide 'test-ui-config--buffer-cursor-state)
-;;; test-ui-config--buffer-cursor-state.el ends here