Add: (link) predicate

This commit is contained in:
Adam Porter 2020-02-23 22:58:08 -06:00
parent 5d720b9fc3
commit 9a56141f6c
5 changed files with 204 additions and 22 deletions

View file

@ -91,6 +91,8 @@ Gotta buy one first, though.
** CHECK /r/emacs :website:Emacs:
DEADLINE: <2017-07-05 Wed +1w>
+ [[http://reddit.com/r/emacs][Link to /r/emacs]]
** TODO Shop for groceries :food:shopping:@town:
SCHEDULED: <2017-07-05 Wed +1w>
:PROPERTIES:

View file

@ -217,6 +217,7 @@ RESULTS should be a list of strings as returned by
:to-equal org-ql-test-num-headings)))
(describe "Query pre-processing"
(it "level:"
(expect (org-ql--pre-process-query '(level "1"))
:to-equal '(level 1))
@ -225,6 +226,19 @@ RESULTS should be a list of strings as returned by
(expect (org-ql--pre-process-query '(level ">" "1"))
:to-equal '(level > 1)))
(describe "(link)"
(it "with one argument"
(expect (org-ql--pre-process-query '(link "DESC-OR-TARGET"))
:to-equal '(link "DESC-OR-TARGET")))
(it "with one argument and :regexp-p"
(expect (org-ql--pre-process-query '(link "DESC-OR-TARGET" :regexp-p t))
:to-equal '(link "DESC-OR-TARGET" :regexp-p t)))
(it "with keyword arguments"
(expect (org-ql--pre-process-query '(link :description "DESCRIPTION" :target "TARGET"
:regexp-p t))
:to-equal '(link :description "DESCRIPTION" :target "TARGET"
:regexp-p t))))
(expect (org-ql--pre-process-query '(and "string1" "string2"))
:to-equal '(and (regexp "string1") (regexp "string2")))
(expect (org-ql--pre-process-query '(or "string1" "string2"))
@ -575,6 +589,23 @@ RESULTS should be a list of strings as returned by
(org-ql-expect ((heading "Take over" "world"))
'("Take over the world"))))
(describe "(link)"
(org-ql-it "without arguments"
(org-ql-expect ((link))
'("/r/emacs")))
(org-ql-it "with description-or-target"
(org-ql-expect ((link "emacs"))
'("/r/emacs")))
(org-ql-it "with :description"
(org-ql-expect ((link :description "emacs"))
'("/r/emacs")))
(org-ql-it "with :target"
(org-ql-expect ((link :target "reddit.com"))
'("/r/emacs")))
(org-ql-it "with :description and :target"
(org-ql-expect ((link :description "emacs" :target "reddit.com"))
'("/r/emacs"))))
(describe "(outline-path)"
(org-ql-it "with one argument"
(org-ql-expect ((outline-path "symphony"))