Skip to content

Commit

Permalink
add test for trash processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Trevoke committed Apr 17, 2023
1 parent aad6d09 commit 58dd0b7
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 29 deletions.
3 changes: 2 additions & 1 deletion org-gtd-trash.el
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
(defun org-gtd-trash--apply ()
"Mark GTD inbox item as cancelled and move it to the org-gtd task archives."
(org-todo org-gtd-canceled)
(with-org-gtd-context (org-archive-subtree)))
(with-org-gtd-context
(org-gtd-archive-item-at-point)))

(provide 'org-gtd-trash)
;;; org-gtd-trash.el ends here
4 changes: 4 additions & 0 deletions test/helpers/clarifying.el
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@

(defun ogt-clarify-as-knowledge-item ()
(execute-kbd-macro (kbd "C-c c k")))


(defun ogt-clarify-as-trash-item ()
(execute-kbd-macro (kbd "C-c c t")))
5 changes: 5 additions & 0 deletions test/helpers/processing.el
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,8 @@
(with-simulated-input project-heading-simulated-input
(org-gtd-organize-inbox-item
org-gtd-organize-add-to-project-func)))

(defun ogt-capture-and-process-trash-item (label)
(ogt-capture-single-item label)
(org-gtd-process-inbox)
(ogt-clarify-as-trash-item))
45 changes: 17 additions & 28 deletions test/processing-test.el
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,19 @@

(execute-kbd-macro (kbd "M-> RET"))
(insert ogt--project-text)
(execute-kbd-macro (kbd "C-c c p"))
(ogt-clarify-as-project)

(execute-kbd-macro (kbd "C-c c c RET"))

(execute-kbd-macro (kbd "C-c c d RET Someone RET"))

(execute-kbd-macro (kbd "C-c c i RET"))

(execute-kbd-macro (kbd "C-c c s"))

(execute-kbd-macro (kbd "C-c c k"))
(ogt-clarify-as-calendar-item)
(ogt-clarify-as-delegated-item "Someone")
(ogt-clarify-as-incubated-item)
(ogt-clarify-as-single-action)
(ogt-clarify-as-knowledge-item)

(execute-kbd-macro (kbd "M-> RET"))
(insert ogt--project-text)
(execute-kbd-macro (kbd "C-c c p"))
(ogt-clarify-as-project)

(execute-kbd-macro (kbd "C-c c c RET"))
(ogt-clarify-as-calendar-item)

(dotimes (x 8)
(ogt-capture-single-item (format "single action %s" x)))
Expand All @@ -51,22 +47,15 @@

(execute-kbd-macro (kbd "M-> RET"))
(insert ogt--project-text)
(execute-kbd-macro (kbd "C-c c p"))

(execute-kbd-macro (kbd "C-c c s"))

(execute-kbd-macro (kbd "C-c c s"))

(execute-kbd-macro (kbd "C-c c c RET"))

(execute-kbd-macro (kbd "C-c c d RET Someone RET"))

(execute-kbd-macro (kbd "C-c c i RET"))

(execute-kbd-macro (kbd "C-c c s"))

(execute-kbd-macro (kbd "C-c c k"))

(ogt-clarify-as-project)

(ogt-clarify-as-single-action)
(ogt-clarify-as-single-action)
(ogt-clarify-as-calendar-item)
(ogt-clarify-as-delegated-item "Someone")
(ogt-clarify-as-incubated-item)
(ogt-clarify-as-single-action)
(ogt-clarify-as-knowledge-item)

(with-current-buffer (org-gtd--inbox-file)
(expect (ogt--current-buffer-raw-text)
Expand Down
17 changes: 17 additions & 0 deletions test/trash-test.el
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
;; -*- lexical-binding: t; coding: utf-8 -*-

(load "test/helpers/setup.el")
(require 'org-gtd)
(require 'buttercup)
(require 'with-simulated-input)

(describe
"Processing a trash item"

(before-each (ogt--configure-emacs))
(after-each (ogt--close-and-delete-files))

(it "through the inbox, mark a task as trash"
(ogt-capture-and-process-trash-item "Yowza")
(with-current-buffer (ogt--archive)
(expect (buffer-string) :to-match "Yowza"))))

0 comments on commit 58dd0b7

Please sign in to comment.