[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 63c5cac: test-org-agenda.el: Test bulk functions
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 63c5cac: test-org-agenda.el: Test bulk functions |
Date: |
Sat, 27 Feb 2021 17:57:10 -0500 (EST) |
branch: externals/org
commit 63c5cacb01775fc2866c3a5a854565f01bc06b73
Author: Kevin J. Foley <kevin@kevinjfoley.me>
Commit: Kyle Meyer <kyle@kyleam.com>
test-org-agenda.el: Test bulk functions
* testing/lisp/test-org-agenda.el (org-test-agenda-with-agenda):
Create macro to setup agenda for tests.
(test-org-agenda/bulk): Test that bulk actions are applied to marked
items.
(test-org-agenda/bulk-custom): Test that custom bulk actions are
applied to marked items.
(test-org-agenda/bulk-custom-arg-func): Test that argument collection
function is properly called for custom bulk functions.
---
testing/lisp/test-org-agenda.el | 68 +++++++++++++++++++++++++++++++++++++++++
1 file changed, 68 insertions(+)
diff --git a/testing/lisp/test-org-agenda.el b/testing/lisp/test-org-agenda.el
index e1c64d8..0efcdc2 100644
--- a/testing/lisp/test-org-agenda.el
+++ b/testing/lisp/test-org-agenda.el
@@ -42,6 +42,13 @@
(mapc #'kill-buffer
(org-test-agenda--agenda-buffers)))
+(defmacro org-test-agenda-with-agenda (text &rest body)
+ (declare (indent 1))
+ `(org-test-with-temp-text-in-file ,text
+ (let ((org-agenda-files `(,buffer-file-name)))
+ ,@body
+ (org-test-agenda--kill-all-agendas))))
+
;; Test the Agenda
@@ -192,6 +199,67 @@
(should (search-forward "f0bcf0cd8bad93c1451bb6e1b2aaedef5cce7cbb" nil t))
(org-test-agenda--kill-all-agendas)))
+;; agenda bulk actions
+
+(ert-deftest test-org-agenda/bulk ()
+ "Bulk actions are applied to marked items."
+ (org-test-agenda-with-agenda "* TODO a\n* TODO b"
+ (org-todo-list)
+ (org-agenda-bulk-mark-all)
+ (cl-letf (((symbol-function 'read-char-exclusive)
+ (lambda () ?t))
+ ((symbol-function 'completing-read)
+ (lambda (&rest rest) "DONE")))
+ (org-agenda-bulk-action))
+ (org-agenda-previous-item 99)
+ (should (looking-at ".*DONE a"))
+ (org-agenda-next-item 1)
+ (should (looking-at ".*DONE b"))))
+
+(ert-deftest test-org-agenda/bulk-custom ()
+ "Custom bulk actions are applied to all marked items."
+ (org-test-agenda-with-agenda "* TODO a\n* TODO b"
+ (org-todo-list)
+ (org-agenda-bulk-mark-all)
+
+ ;; Mock read functions
+ (let* ((f-call-cnt 0)
+ (org-agenda-bulk-custom-functions
+ `((?P ,(lambda () (setq f-call-cnt (1+ f-call-cnt)))))))
+ (cl-letf* (((symbol-function 'read-char-exclusive)
+ (lambda () ?P)))
+ (org-agenda-bulk-action)
+ (should (= f-call-cnt 2))))))
+
+(ert-deftest test-org-agenda/bulk-custom-arg-func ()
+ "Argument collection functions can be specified for custom bulk
+functions."
+ (org-test-agenda-with-agenda "* TODO a\n* TODO b"
+ (org-todo-list)
+ (org-agenda-bulk-mark-all)
+ (let* ((f-called-cnt 0)
+ (arg-f-call-cnt 0)
+ (f-called-args nil)
+ (org-agenda-bulk-custom-functions
+ `((?P
+ ;; Custom bulk function
+ ,(lambda (&rest args)
+ (message "test" args)
+ (setq f-called-cnt (1+ f-called-cnt)
+
+ f-called-args args))
+ ;; Argument collection function
+ ,(lambda ()
+ (setq arg-f-call-cnt (1+ arg-f-call-cnt))
+ '(1 2 3))))))
+ (cl-letf (((symbol-function 'read-char-exclusive)
+ (lambda () ?P)))
+ (org-agenda-bulk-action))
+ (should (= f-called-cnt 2))
+ (should (= arg-f-call-cnt 1))
+ (should (equal f-called-args '(1 2 3))))))
+
+
(provide 'test-org-agenda)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] externals/org 63c5cac: test-org-agenda.el: Test bulk functions,
ELPA Syncer <=