From 22af1d98bcfe8dc970ee134f50d00c3ed31efe79 Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Tue, 5 May 2026 14:46:43 -0500 Subject: test: cover org-drill-test-display dev helper I added a test for the developer helper `org-drill-test-display' that mocks `org-drill-entry-f' to confirm the dispatcher fires and that the zysygy tag is toggled off again on exit. I also added a small case for `org-drill-test-display-rescheduler' that verifies it runs `org-drill-display-answer-hook' and waits on read-key-sequence. Coverage moved from 92.7% to 93.2%. --- tests/test-org-drill-small-branch-coverage.el | 30 +++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'tests') diff --git a/tests/test-org-drill-small-branch-coverage.el b/tests/test-org-drill-small-branch-coverage.el index 4e50f3d..db1a2e9 100644 --- a/tests/test-org-drill-small-branch-coverage.el +++ b/tests/test-org-drill-small-branch-coverage.el @@ -75,6 +75,36 @@ read and re-activates it on the way out." ((symbol-function 'org-drill-entry-p) (lambda (&rest _) nil))) (should-error (org-drill-goto-drill-entry-heading))))) +;;;; org-drill-test-display (developer helper) + +(ert-deftest test-org-drill-test-display-toggles-zysygy-tag () + "The dev helper toggles a `zysygy' tag on, runs entry-f, then toggles off." + (with-temp-buffer + (insert "* Item\nbody\n") + (org-mode) + (goto-char (point-min)) + (let ((entry-f-called nil)) + (cl-letf (((symbol-function 'org-drill-entry-f) + (lambda (&rest _) (setq entry-f-called t))) + ((symbol-function 'org-drill-test-display-rescheduler) #'ignore)) + (org-drill-test-display)) + (should entry-f-called) + ;; Tag was toggled off in the unwind-protect cleanup, so the + ;; entry should not be tagged. + (should-not (member "zysygy" (org-get-tags)))))) + +(ert-deftest test-org-drill-test-display-rescheduler-runs-hook-and-reads-key () + "The rescheduler runs the answer hook and waits on read-key-sequence." + (let ((hook-ran nil) + (key-read nil)) + (let ((org-drill-display-answer-hook + (list (lambda () (setq hook-ran t))))) + (cl-letf (((symbol-function 'read-key-sequence) + (lambda (&rest _) (setq key-read t) "x"))) + (org-drill-test-display-rescheduler nil))) + (should hook-ran) + (should key-read))) + ;;;; org-drill-add-cloze-fontification (ert-deftest test-add-cloze-fontification-with-flag-extends-keywords () -- cgit v1.2.3