diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-05 14:46:43 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-05 14:46:43 -0500 |
| commit | 22af1d98bcfe8dc970ee134f50d00c3ed31efe79 (patch) | |
| tree | a1ecbc5374b6fc22a7b30c157a869b8eef84c728 /tests | |
| parent | 962cf79cfbfaa943a09e530b4a73b1fcafe1f220 (diff) | |
| download | org-drill-22af1d98bcfe8dc970ee134f50d00c3ed31efe79.tar.gz org-drill-22af1d98bcfe8dc970ee134f50d00c3ed31efe79.zip | |
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%.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/test-org-drill-small-branch-coverage.el | 30 |
1 files changed, 30 insertions, 0 deletions
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 () |
