Skip to content

Commit

Permalink
Tests: Timestamps with inner time ranges
Browse files Browse the repository at this point in the history
  • Loading branch information
alphapapa committed Jun 26, 2024
1 parent 84d0b34 commit f06cf3f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
23 changes: 23 additions & 0 deletions tests/data-ts.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#+title: Timestamp-specific tests

/Timestamps in this file are active ones./

* Single-timestamp ranges

** Single-timestamp, without repeater
<2024-06-25 Tue 08:00-09:00>

** Single-timestamp, with repeater (deadline)
DEADLINE: <2024-06-25 Tue 08:00-09:00 ++7d>

* Multi-timestamp ranges

/Not sure that it would make sense to use repeaters for this kind of range./

** Multi-timestamp, without repeater
<2024-06-25 Tue 08:00>--<2024-06-26 Wed 08:00>

* Canary

/This entry should never be matched./

21 changes: 20 additions & 1 deletion tests/test-org-ql.el
Original file line number Diff line number Diff line change
Expand Up @@ -1690,7 +1690,26 @@ with keyword arg NOW in PLIST."
(org-ql-expect ((org-ql--query-string-to-sexp "ts-active:with-time="))
'("Take over the universe" "Take over the world" "Visit Mars" "Visit the moon" "Practice leaping tall buildings in a single bound" "Get haircut" "Internet" "Spaceship lease" "Fix flux capacitor" "/r/emacs" "Shop for groceries" "Rewrite Emacs in Common Lisp"))
(org-ql-expect ((org-ql--query-string-to-sexp "ts-active:with-time=t"))
'("Skype with president of Antarctica" "Renew membership in supervillain club" "Order a pizza"))))
'("Skype with president of Antarctica" "Renew membership in supervillain club" "Order a pizza")))

(describe "matches timestamps with inner time ranges"
(before-each
(setq org-ql-test-buffer (org-ql-test-data-buffer "data-ts.org")
org-ql-test-num-headings (with-current-buffer org-ql-test-buffer
(org-with-wide-buffer
(goto-char (point-min))
;; Exclude the "Canary" heading.
(1- (cl-loop while (re-search-forward org-heading-regexp nil t)
sum 1))))))

(org-ql-it "without specified timestamp"
(org-ql-expect ('(ts-active))
'("Single-timestamp, without repeater" "Single-timestamp, with repeater (deadline)" "Multi-timestamp, without repeater")))
(org-ql-it "with specified timestamps"
(org-ql-expect ('(ts-active :on "2024-06-25"))
'("Single-timestamp, without repeater" "Single-timestamp, with repeater (deadline)" "Multi-timestamp, without repeater"))
(org-ql-expect ('(ts-active :on "2024-06-26"))
'("Multi-timestamp, without repeater")))))

(describe "inactive"

Expand Down

0 comments on commit f06cf3f

Please sign in to comment.