diff options
| author | Craig Jennings <c@cjennings.net> | 2026-04-30 08:33:31 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-04-30 09:13:53 -0500 |
| commit | eaf3848e7893326f2ddaaab23633106e0afe8fd8 (patch) | |
| tree | 9950289ddbfd1ab39eccc51c350a521fd3377717 /tests/test-org-noter-config--preferred-split.el | |
| parent | 0fb3ae438277146a1167cc46ed6c3218a14281ff (diff) | |
| download | dotemacs-eaf3848e7893326f2ddaaab23633106e0afe8fd8.tar.gz dotemacs-eaf3848e7893326f2ddaaab23633106e0afe8fd8.zip | |
test(org-noter-config): cover preferred-split, slug, template, predicates
Four new test files for the pure-and-near-pure helpers in
org-noter-config.el. The interactive heavyweights (cj/org-noter-start,
cj/org-noter-insert-note-dwim, cj/org-noter--toggle-notes-window,
cj/org-noter--find-notes-file, cj/org-noter--create-notes-file) are
out of scope for this pass — they need org-noter loaded and a real
session, or a substantial internal/wrapper split before they can be
tested without spinning up real PDFs and EPUBs.
- preferred-split: 5 tests walking the 1.4 width-to-height threshold
from both sides plus a square-frame boundary.
- title-to-slug: 7 tests covering multi-word, single-word, mixed
punctuation, leading/trailing junk, collapsed runs, digits, and
empty input.
- generate-notes-template: 5 tests with org-id-uuid mocked, asserting
the rendered template carries the UUID, the dual ROAM_REFS /
NOTER_DOCUMENT pointers, the title-and-category lines, the
ReadingNotes filetag, and the trailing Notes heading.
- predicates: 13 tests covering cj/org-noter--in-document-p,
cj/org-noter--in-notes-file-p, cj/org-noter--session-active-p,
cj/org-noter--get-document-path, and cj/org-noter--extract-document-title.
Mocks derived-mode-p, org-entry-get, and buffer-file-name at the
boundary so the suite doesn't require pdf-tools or nov.
The require chain in each test file is user-constants → keybindings →
org-noter-config because cj/org-noter-notes-directory captures
roam-dir from user-constants and the prefix-map binding at the bottom
of org-noter-config references cj/custom-keymap.
30 new tests, all passing. Full suite green.
Diffstat (limited to 'tests/test-org-noter-config--preferred-split.el')
| -rw-r--r-- | tests/test-org-noter-config--preferred-split.el | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/test-org-noter-config--preferred-split.el b/tests/test-org-noter-config--preferred-split.el new file mode 100644 index 00000000..c99d63f4 --- /dev/null +++ b/tests/test-org-noter-config--preferred-split.el @@ -0,0 +1,52 @@ +;;; test-org-noter-config--preferred-split.el --- Tests for cj/org-noter--preferred-split -*- lexical-binding: t; -*- + +;;; Commentary: +;; Tests for `cj/org-noter--preferred-split'. The function returns +;; `horizontal-split' when the frame's width-to-height ratio exceeds +;; 1.4, otherwise `vertical-split'. Tests mock the frame-pixel-* +;; primitives to walk the threshold from both sides. + +;;; Code: + +(require 'ert) +(require 'cl-lib) + +(add-to-list 'load-path (expand-file-name "modules" user-emacs-directory)) +(require 'user-constants) +(require 'keybindings) +(require 'org-noter-config) + +(defmacro test-org-noter-config--with-frame-size (width height &rest body) + "Run BODY with `frame-pixel-width' / `frame-pixel-height' mocked to WIDTH and HEIGHT." + (declare (indent 2) (debug t)) + `(cl-letf (((symbol-function 'frame-pixel-width) (lambda (&optional _) ,width)) + ((symbol-function 'frame-pixel-height) (lambda (&optional _) ,height))) + ,@body)) + +(ert-deftest test-org-noter-config-preferred-split-wide-returns-horizontal () + "Normal: a 16:9 wide frame returns horizontal-split (side-by-side)." + (test-org-noter-config--with-frame-size 1920 1080 + (should (eq 'horizontal-split (cj/org-noter--preferred-split))))) + +(ert-deftest test-org-noter-config-preferred-split-tall-returns-vertical () + "Normal: a tall portrait frame returns vertical-split (stacked)." + (test-org-noter-config--with-frame-size 800 1200 + (should (eq 'vertical-split (cj/org-noter--preferred-split))))) + +(ert-deftest test-org-noter-config-preferred-split-square-returns-vertical () + "Boundary: a square frame is below the 1.4 threshold; returns vertical." + (test-org-noter-config--with-frame-size 1000 1000 + (should (eq 'vertical-split (cj/org-noter--preferred-split))))) + +(ert-deftest test-org-noter-config-preferred-split-just-above-threshold-horizontal () + "Boundary: a width-to-height ratio of 1.5 returns horizontal." + (test-org-noter-config--with-frame-size 1500 1000 + (should (eq 'horizontal-split (cj/org-noter--preferred-split))))) + +(ert-deftest test-org-noter-config-preferred-split-just-below-threshold-vertical () + "Boundary: a width-to-height ratio of 1.3 returns vertical." + (test-org-noter-config--with-frame-size 1300 1000 + (should (eq 'vertical-split (cj/org-noter--preferred-split))))) + +(provide 'test-org-noter-config--preferred-split) +;;; test-org-noter-config--preferred-split.el ends here |
