aboutsummaryrefslogtreecommitdiff
path: root/tests/test-nov-reading--config-defaults.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-07-06 08:43:03 -0500
committerCraig Jennings <c@cjennings.net>2026-07-06 08:43:03 -0500
commit648c150f6e4e89c9c04158795da1ab13370d7f73 (patch)
tree442f9349e0904a4c00cb57c076e13f1152614fe5 /tests/test-nov-reading--config-defaults.el
parentf613bd63811d84816f88d26b33323e1b0f395793 (diff)
downloaddotemacs-648c150f6e4e89c9c04158795da1ab13370d7f73.tar.gz
dotemacs-648c150f6e4e89c9c04158795da1ab13370d7f73.zip
feat(readers): default EPUB and PDF to a dark/sepia/light reading cycle
nov-mode's reading cycle opened on sepia and ran sepia, dark, light. I reordered it to dark, sepia, light and made a fresh EPUB open dark. pdf-view only had a binary midnight toggle. I added a matching palette layer: a fresh PDF opens dark, and c cycles dark, sepia, light, none (C selects by name, M also cycles). Each palette is a foreground/background pair fed to pdf-view-midnight-minor-mode, so sepia and light are that same duotone with warmer and lighter colors. The pdf colors mirror the nov palettes so EPUBs and PDFs read alike. Pure name-to-colors and cycle logic are unit-tested. The live render needs a manual check.
Diffstat (limited to 'tests/test-nov-reading--config-defaults.el')
-rw-r--r--tests/test-nov-reading--config-defaults.el38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/test-nov-reading--config-defaults.el b/tests/test-nov-reading--config-defaults.el
new file mode 100644
index 00000000..5e454ce1
--- /dev/null
+++ b/tests/test-nov-reading--config-defaults.el
@@ -0,0 +1,38 @@
+;;; test-nov-reading--config-defaults.el --- nov reading default/order tests -*- lexical-binding: t; -*-
+
+;;; Commentary:
+;; Asserts the shipped reading-view defaults: a fresh EPUB opens dark, and the
+;; `c' cycle runs dark -> sepia -> light -> none -> back. The pure-logic file
+;; test-nov-reading--palette.el covers the cycle mechanics on fixtures; this file
+;; pins the real `cj/nov-reading-palettes' / `cj/nov-reading-default-palette'
+;; values so a reorder can't silently drift the default or the cycle order.
+
+;;; Code:
+
+(require 'ert)
+(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory))
+(require 'nov-reading)
+
+(declare-function cj/nov--next-reading-palette "nov-reading" (current names))
+(defvar cj/nov-reading-palettes)
+(defvar cj/nov-reading-default-palette)
+
+(ert-deftest test-nov-reading-config-default-is-dark ()
+ "Normal: a fresh nov buffer opens on the dark palette."
+ (should (equal cj/nov-reading-default-palette "dark")))
+
+(ert-deftest test-nov-reading-config-order-is-dark-sepia-light ()
+ "Normal: the shipped palette order is dark, then sepia, then light."
+ (should (equal (mapcar #'car cj/nov-reading-palettes)
+ '("dark" "sepia" "light"))))
+
+(ert-deftest test-nov-reading-config-cycle-from-default ()
+ "Normal: cycling from the default advances dark -> sepia -> light -> none -> dark."
+ (let ((names (mapcar #'car cj/nov-reading-palettes)))
+ (should (equal (cj/nov--next-reading-palette "dark" names) "sepia"))
+ (should (equal (cj/nov--next-reading-palette "sepia" names) "light"))
+ (should-not (cj/nov--next-reading-palette "light" names))
+ (should (equal (cj/nov--next-reading-palette nil names) "dark"))))
+
+(provide 'test-nov-reading--config-defaults)
+;;; test-nov-reading--config-defaults.el ends here