aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-24 15:31:07 -0500
committerCraig Jennings <c@cjennings.net>2026-05-24 15:31:07 -0500
commitc6a81743f95638bc8275bea1b590f4ca9f7cbc39 (patch)
tree074a8308eb30199abd30b0e0fac418e36ed11697 /tests
parent810665a72ddb7721585e045113a82a8c218072e7 (diff)
downloaddotemacs-c6a81743f95638bc8275bea1b590f4ca9f7cbc39.tar.gz
dotemacs-c6a81743f95638bc8275bea1b590f4ca9f7cbc39.zip
test: cover markdown-html filter and media-player selector
Two real-logic gaps from the refreshed coverage backlog. cj/markdown-html (markdown-config) is the impatient-mode filter that wraps a source buffer's text in the strapdown HTML shell — tested for normal content and an empty buffer. cj/select-media-player (media-utils) was the one untested function there — tested that choosing an available player updates cj/default-media-player and that a non-matching selection leaves it unchanged. Both mock at the boundary (completing-read, the source buffer).
Diffstat (limited to 'tests')
-rw-r--r--tests/test-markdown-config.el27
-rw-r--r--tests/test-media-utils.el26
2 files changed, 53 insertions, 0 deletions
diff --git a/tests/test-markdown-config.el b/tests/test-markdown-config.el
index 62d199a8..45e1a601 100644
--- a/tests/test-markdown-config.el
+++ b/tests/test-markdown-config.el
@@ -23,5 +23,32 @@
`C-c '' opens those blocks in `markdown-mode'."
(should (equal (cdr (assoc "markdown" org-src-lang-modes)) 'markdown)))
+;;; cj/markdown-html (impatient-mode filter: source buffer -> HTML)
+
+(ert-deftest test-markdown-html-wraps-source-buffer-content ()
+ "Normal: the source buffer's text is embedded in the strapdown HTML shell."
+ (let ((src (generate-new-buffer " *md-src*")))
+ (unwind-protect
+ (progn
+ (with-current-buffer src (insert "# Title\n\nsome **markdown**"))
+ (with-temp-buffer
+ (cj/markdown-html src)
+ (let ((html (buffer-string)))
+ (should (string-match-p "<!DOCTYPE html>" html))
+ (should (string-match-p "<xmp" html))
+ (should (string-match-p "strapdown\\.js" html))
+ (should (string-match-p "some \\*\\*markdown\\*\\*" html)))))
+ (kill-buffer src))))
+
+(ert-deftest test-markdown-html-empty-source-buffer ()
+ "Boundary: an empty source buffer still yields the HTML shell."
+ (let ((src (generate-new-buffer " *md-empty*")))
+ (unwind-protect
+ (with-temp-buffer
+ (cj/markdown-html src)
+ (should (string-match-p "<!DOCTYPE html>" (buffer-string)))
+ (should (string-match-p "<xmp" (buffer-string))))
+ (kill-buffer src))))
+
(provide 'test-markdown-config)
;;; test-markdown-config.el ends here
diff --git a/tests/test-media-utils.el b/tests/test-media-utils.el
index 85ee826f..9384d568 100644
--- a/tests/test-media-utils.el
+++ b/tests/test-media-utils.el
@@ -101,5 +101,31 @@
(should (member "yt-dlp" captured))
(should (member "https://example.com/v" captured))))
+;; ---------------------------- cj/select-media-player -------------------------
+
+(ert-deftest test-media-select-player-normal-sets-default-on-choice ()
+ "Normal: choosing an available player updates `cj/default-media-player'."
+ (let ((cj/media-players '((mpv . (:name "mpv" :command "mpv"))
+ (vlc . (:name "VLC" :command "vlc"))))
+ (cj/default-media-player 'vlc))
+ (cl-letf (((symbol-function 'cj/get-available-media-players)
+ (lambda () '(mpv vlc)))
+ ((symbol-function 'completing-read) (lambda (&rest _) "mpv"))
+ ((symbol-function 'message) #'ignore))
+ (cj/select-media-player)
+ (should (eq cj/default-media-player 'mpv)))))
+
+(ert-deftest test-media-select-player-boundary-no-match-keeps-default ()
+ "Boundary: a selection matching no player leaves the default unchanged."
+ (let ((cj/media-players '((mpv . (:name "mpv" :command "mpv"))
+ (vlc . (:name "VLC" :command "vlc"))))
+ (cj/default-media-player 'vlc))
+ (cl-letf (((symbol-function 'cj/get-available-media-players)
+ (lambda () '(mpv vlc)))
+ ((symbol-function 'completing-read) (lambda (&rest _) "Nonexistent"))
+ ((symbol-function 'message) #'ignore))
+ (cj/select-media-player)
+ (should (eq cj/default-media-player 'vlc)))))
+
(provide 'test-media-utils)
;;; test-media-utils.el ends here