aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test-org-drill-mode.el52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/test-org-drill-mode.el b/tests/test-org-drill-mode.el
index 2050feb..2760b31 100644
--- a/tests/test-org-drill-mode.el
+++ b/tests/test-org-drill-mode.el
@@ -75,6 +75,48 @@ character of the first occurrence of literal string S."
(org-mode)
(should-not (org-drill-buffer-has-cards-p))))
+;;;; Drill-buffer predicate — file-level tags (#+FILETAGS), upstream bug
+
+(ert-deftest test-org-drill-buffer-has-cards-p-true-for-filetags-space ()
+ "A deck that tags its cards via `#+FILETAGS: drill' (space syntax, no
+per-heading tag) counts as a drill buffer."
+ (with-temp-buffer
+ (insert "#+FILETAGS: drill\n* A card\nQ [answer] A\n")
+ (org-mode)
+ (should (org-drill-buffer-has-cards-p))))
+
+(ert-deftest test-org-drill-buffer-has-cards-p-true-for-filetags-colon ()
+ "A deck tagged via the colon syntax `#+FILETAGS: :spanish:drill:verbs:'
+counts as a drill buffer even when the tag sits among others."
+ (with-temp-buffer
+ (insert "#+FILETAGS: :spanish:drill:verbs:\n* A card\nQ [answer] A\n")
+ (org-mode)
+ (should (org-drill-buffer-has-cards-p))))
+
+(ert-deftest test-org-drill-buffer-has-cards-p-true-for-filetags-leitner ()
+ "A deck tagged via `#+FILETAGS: leitner' counts as a drill buffer."
+ (with-temp-buffer
+ (insert "#+FILETAGS: leitner\n* A card\nQ [answer] A\n")
+ (org-mode)
+ (should (org-drill-buffer-has-cards-p))))
+
+(ert-deftest test-org-drill-buffer-has-cards-p-true-for-inherited-top-level-tag ()
+ "A deck whose cards inherit the tag from a tagged top-level heading counts
+as a drill buffer. The ancestor heading line carries the literal tag, so the
+per-heading scan already matches it — this locks that in."
+ (with-temp-buffer
+ (insert "* Deck :drill:\n** Card 1\nQ [answer] A\n** Card 2\nQ2 [answer2] A2\n")
+ (org-mode)
+ (should (org-drill-buffer-has-cards-p))))
+
+(ert-deftest test-org-drill-buffer-has-cards-p-false-for-filetags-substring ()
+ "A `#+FILETAGS:' value that merely contains the tag as a substring
+\(e.g. `drilldown') must NOT count as a drill buffer."
+ (with-temp-buffer
+ (insert "#+FILETAGS: drilldown\n* Notes\nbody\n")
+ (org-mode)
+ (should-not (org-drill-buffer-has-cards-p))))
+
;;;; Auto-enable on org-mode-hook
(ert-deftest test-org-drill-mode-auto-enables-in-drill-buffer ()
@@ -85,6 +127,16 @@ character of the first occurrence of literal string S."
(org-mode)
(should org-drill-mode))))
+(ert-deftest test-org-drill-mode-auto-enables-in-filetags-buffer ()
+ "With auto-enable on, opening a deck tagged only via `#+FILETAGS: drill'
+turns the mode on. This is the user-facing bug: filetag-only decks were
+left without cloze highlighting."
+ (let ((org-drill-auto-enable-mode t))
+ (with-temp-buffer
+ (insert "#+FILETAGS: drill\n* A card\nQ [answer] A\n")
+ (org-mode)
+ (should org-drill-mode))))
+
(ert-deftest test-org-drill-mode-does-not-auto-enable-in-plain-buffer ()
"With auto-enable on, a plain org buffer does NOT turn the mode on."
(let ((org-drill-auto-enable-mode t))