aboutsummaryrefslogtreecommitdiff
path: root/tests/test-org-drill-route-rating-result.el
diff options
context:
space:
mode:
authorCraig Jennings <c@cjennings.net>2026-05-05 14:35:45 -0500
committerCraig Jennings <c@cjennings.net>2026-05-05 14:35:45 -0500
commitdf4caddc17091b67b5afa7864b53ccffc00ce076 (patch)
tree8243b853af8a4a1d3c2664a988ed0617090a8b68 /tests/test-org-drill-route-rating-result.el
parent46bcf53e970e05f6c58b08040a72cc61cc476fb4 (diff)
downloadorg-drill-df4caddc17091b67b5afa7864b53ccffc00ce076.tar.gz
org-drill-df4caddc17091b67b5afa7864b53ccffc00ce076.zip
test: cover --pick-next-marker and resume happy-paths
I extended `tests/test-org-drill-route-rating-result.el' with four `org-drill--pick-next-marker' cases (no resume → pop, resume with live drill marker → keep current-item and clear resume-p, resume with nil or non-drill current-item → fall through to fresh pop). I also extended the resume regression file with the three happy-path branches of `org-drill-resume': pending entries → resume, finished with pending count → y-or-n-p offers a new session, finished with nothing → print 'finished'. Coverage moved from 91.7% to 92.1%.
Diffstat (limited to 'tests/test-org-drill-route-rating-result.el')
-rw-r--r--tests/test-org-drill-route-rating-result.el50
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/test-org-drill-route-rating-result.el b/tests/test-org-drill-route-rating-result.el
index 5469bc8..5ea29b7 100644
--- a/tests/test-org-drill-route-rating-result.el
+++ b/tests/test-org-drill-route-rating-result.el
@@ -67,5 +67,55 @@
(org-drill--route-rating-result session m1 0))
(should shuffle-called)))
+;;;; org-drill--pick-next-marker
+
+(ert-deftest test-pick-next-marker-not-resuming-pops-from-queue ()
+ "Without resuming-p, the result is the popped pending entry."
+ (let ((session (org-drill-session)))
+ (cl-letf (((symbol-function 'org-drill-pop-next-pending-entry)
+ (lambda (_) 'popped-marker)))
+ (let ((result (org-drill--pick-next-marker session nil)))
+ (should (equal '(popped-marker . nil) result))))))
+
+(ert-deftest test-pick-next-marker-resuming-with-current-item-keeps-it ()
+ "When resuming-p is t and current-item is a live drill entry, return it
+and flip resume-p to nil so subsequent ticks don't repeat the same entry."
+ (let ((session (org-drill-session)))
+ (with-temp-buffer
+ (insert "* Drill :drill:\nbody\n")
+ (org-mode)
+ (goto-char (point-min))
+ (let ((m (point-marker)))
+ (oset session current-item m)
+ (let ((result (org-drill--pick-next-marker session t)))
+ (should (eq m (car result)))
+ (should (null (cdr result))))))))
+
+(ert-deftest test-pick-next-marker-resuming-with-nil-current-item-pops-fresh ()
+ "When resuming-p is t but current-item is nil, fall through to popping a
+fresh entry from the pending queue."
+ (let ((session (org-drill-session)))
+ (oset session current-item nil)
+ (cl-letf (((symbol-function 'org-drill-pop-next-pending-entry)
+ (lambda (_) 'fresh-marker)))
+ (let ((result (org-drill--pick-next-marker session t)))
+ (should (eq 'fresh-marker (car result)))
+ ;; resuming-p still flowing through.
+ (should (eq t (cdr result)))))))
+
+(ert-deftest test-pick-next-marker-resuming-with-non-drill-current-item-pops-fresh ()
+ "When current-item is set but no longer points at a drill entry, fall
+through to popping a fresh entry."
+ (let ((session (org-drill-session)))
+ (with-temp-buffer
+ (insert "Plain text — not a drill heading.\n")
+ (org-mode)
+ (goto-char (point-min))
+ (oset session current-item (point-marker))
+ (cl-letf (((symbol-function 'org-drill-pop-next-pending-entry)
+ (lambda (_) 'fresh-marker)))
+ (let ((result (org-drill--pick-next-marker session t)))
+ (should (eq 'fresh-marker (car result))))))))
+
(provide 'test-org-drill-route-rating-result)
;;; test-org-drill-route-rating-result.el ends here