org-clock: Add test
* testing/lisp/test-org-clock.el (test-org-clock/clocktable/link): New test.
This commit is contained in:
parent
fc369b6fae
commit
4e5bc38040
|
@ -532,6 +532,130 @@ CLOCK: [2016-12-28 Wed 13:09]--[2016-12-28 Wed 15:09] => 2:00"
|
|||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":maxlevel 1 :lang foo")))))
|
||||
|
||||
(ert-deftest test-org-clock/clocktable/link ()
|
||||
"Test \":link\" parameter in Clock table."
|
||||
;; If there is no file attached to the document, link directly to
|
||||
;; the headline.
|
||||
(should
|
||||
(equal
|
||||
"| Headline | Time | |
|
||||
|--------------+---------+---|
|
||||
| *Total time* | *26:00* | |
|
||||
|--------------+---------+---|
|
||||
| [[Foo][Foo]] | 26:00 | |"
|
||||
(org-test-with-temp-text
|
||||
"* Foo
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t"))))
|
||||
;; Otherwise, link to the headline in the current file.
|
||||
(should
|
||||
(equal
|
||||
"| Headline | Time | |
|
||||
|--------------+---------+---|
|
||||
| *Total time* | *26:00* | |
|
||||
|--------------+---------+---|
|
||||
| [[file:filename::Foo][Foo]] | 26:00 | |"
|
||||
(org-test-with-temp-text-in-file
|
||||
"* Foo
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(let ((file (buffer-file-name)))
|
||||
(replace-regexp-in-string
|
||||
(regexp-quote file) "filename"
|
||||
(test-org-clock-clocktable-contents ":link t"))))))
|
||||
;; Ignore TODO keyword, priority cookie, COMMENT and tags in
|
||||
;; headline.
|
||||
(should
|
||||
(equal
|
||||
"| Headline | Time | |
|
||||
|--------------+---------+---|
|
||||
| *Total time* | *26:00* | |
|
||||
|--------------+---------+---|
|
||||
| [[Foo][Foo]] | 26:00 | |"
|
||||
(org-test-with-temp-text
|
||||
"* TODO Foo
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t"))))
|
||||
(should
|
||||
(equal
|
||||
"| Headline | Time | |
|
||||
|--------------+---------+---|
|
||||
| *Total time* | *26:00* | |
|
||||
|--------------+---------+---|
|
||||
| [[Foo][Foo]] | 26:00 | |"
|
||||
(org-test-with-temp-text
|
||||
"* [#A] Foo
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t"))))
|
||||
(should
|
||||
(equal
|
||||
"| Headline | Time | |
|
||||
|--------------+---------+---|
|
||||
| *Total time* | *26:00* | |
|
||||
|--------------+---------+---|
|
||||
| [[Foo][Foo]] | 26:00 | |"
|
||||
(org-test-with-temp-text
|
||||
"* COMMENT Foo
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t"))))
|
||||
(should
|
||||
(equal
|
||||
"| Headline | Time | |
|
||||
|--------------+---------+---|
|
||||
| *Total time* | *26:00* | |
|
||||
|--------------+---------+---|
|
||||
| [[Foo][Foo]] | 26:00 | |"
|
||||
(org-test-with-temp-text
|
||||
"* Foo :tag:
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t"))))
|
||||
;; Remove statistics cookie from headline description.
|
||||
(should
|
||||
(equal
|
||||
"| Headline | Time | |
|
||||
|--------------+---------+---|
|
||||
| *Total time* | *26:00* | |
|
||||
|--------------+---------+---|
|
||||
| [[Foo][Foo]] | 26:00 | |"
|
||||
(org-test-with-temp-text
|
||||
"* Foo [50%]
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t"))))
|
||||
(should
|
||||
(equal
|
||||
"| Headline | Time | |
|
||||
|--------------+---------+---|
|
||||
| *Total time* | *26:00* | |
|
||||
|--------------+---------+---|
|
||||
| [[Foo][Foo]] | 26:00 | |"
|
||||
(org-test-with-temp-text
|
||||
"* Foo [1/2]
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t"))))
|
||||
;; Replace links with their description, or turn them into plain
|
||||
;; links if there is no description.
|
||||
(should
|
||||
(equal
|
||||
"| Headline | Time | |
|
||||
|--------------+---------+---|
|
||||
| *Total time* | *26:00* | |
|
||||
|--------------+---------+---|
|
||||
| [[Foo%20%5B%5Bhttp://orgmode.org%5D%5BOrg%20mode%5D%5D][Foo Org mode]] | 26:00 | |"
|
||||
(org-test-with-temp-text
|
||||
"* Foo [[http://orgmode.org][Org mode]]
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t"))))
|
||||
(should
|
||||
(equal
|
||||
"| Headline | Time | |
|
||||
|------------------------+---------+---|
|
||||
| *Total time* | *26:00* | |
|
||||
|------------------------+---------+---|
|
||||
| [[Foo%20%5B%5Bhttp://orgmode.org%5D%5D][Foo http://orgmode.org]] | 26:00 | |"
|
||||
(org-test-with-temp-text
|
||||
"* Foo [[http://orgmode.org]]
|
||||
CLOCK: [2016-12-27 Wed 13:09]--[2016-12-28 Wed 15:09] => 26:00"
|
||||
(test-org-clock-clocktable-contents ":link t")))))
|
||||
|
||||
(ert-deftest test-org-clock/clocktable/compact ()
|
||||
"Test \":compact\" parameter in Clock table."
|
||||
;; With :compact, all headlines are in the same column.
|
||||
|
|
Loading…
Reference in New Issue