aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-06-15 23:29:35 -0500
committerCraig Jennings <c@cjennings.net>2026-06-15 23:29:35 -0500
commitc0c6e72684387f990fda1096e842f1f100ddb3e5 (patch)
treec5a310db35ffb543df2773d3c239642b15bfe3d2 /tests
parent07738d4f58f463c20ab70b5f336b2911f5f9d521 (diff)
downloaddotemacs-c0c6e72684387f990fda1096e842f1f100ddb3e5.tar.gz
dotemacs-c0c6e72684387f990fda1096e842f1f100ddb3e5.zip
feat(system-utils): tint the *scratch* background a shade lighter
A buffer-local face remap lightens the *scratch* default background by cj/scratch-background-lighten percent (default 5) so it reads as the scratch buffer, applied on emacs-startup-hook. The colour math is display-dependent (verified live); the pure helper's guard contract is unit-tested.
Diffstat (limited to 'tests')
-rw-r--r--tests/test-system-utils-scratch-background.el30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/test-system-utils-scratch-background.el b/tests/test-system-utils-scratch-background.el
new file mode 100644
index 000000000..422590f4b
--- /dev/null
+++ b/tests/test-system-utils-scratch-background.el
@@ -0,0 +1,30 @@
+;;; test-system-utils-scratch-background.el --- Tests for the scratch tint -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; cj/--scratch-lightened-background lightens the default background by a
+;; tunable percent for the *scratch* buffer's buffer-local face remap. The
+;; colour arithmetic (color-lighten-name -> color-name-to-rgb) is
+;; display-dependent and returns zeros under --batch, so the actual lightening
+;; is verified live in the daemon; here we cover the display-independent
+;; contract: a usable colour string yields a string, junk yields nil.
+
+;;; Code:
+
+(require 'ert)
+(require 'color)
+(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
+(require 'system-utils)
+
+(ert-deftest test-system-utils-scratch-lightened-background-returns-string ()
+ "Normal: a valid hex colour yields a colour string (not nil)."
+ (let ((cj/scratch-background-lighten 5))
+ (should (stringp (cj/--scratch-lightened-background "#100f0f")))))
+
+(ert-deftest test-system-utils-scratch-lightened-background-bad-input ()
+ "Error: non-colour input yields nil rather than signalling."
+ (should (null (cj/--scratch-lightened-background nil)))
+ (should (null (cj/--scratch-lightened-background 'unspecified)))
+ (should (null (cj/--scratch-lightened-background "not-a-color"))))
+
+(provide 'test-system-utils-scratch-background)
+;;; test-system-utils-scratch-background.el ends here