emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] [PATCH 1/2] Add tests for org-refile-get-targets


From: Sebastian Reuße
Subject: [O] [PATCH 1/2] Add tests for org-refile-get-targets
Date: Mon, 15 May 2017 14:54:54 +0200

* testing/lisp/test-org.el: Add test.
---
 testing/examples/refile/a.org |  6 ++++++
 testing/examples/refile/b.org |  6 ++++++
 testing/lisp/test-org.el      | 44 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 56 insertions(+)
 create mode 100644 testing/examples/refile/a.org
 create mode 100644 testing/examples/refile/b.org

diff --git a/testing/examples/refile/a.org b/testing/examples/refile/a.org
new file mode 100644
index 000000000..7ed235a52
--- /dev/null
+++ b/testing/examples/refile/a.org
@@ -0,0 +1,6 @@
+* a/1/1
+** a/1/2
+*** a/1/3
+* a/2/1
+** a/2/2
+*** a/2/3
diff --git a/testing/examples/refile/b.org b/testing/examples/refile/b.org
new file mode 100644
index 000000000..15359b16e
--- /dev/null
+++ b/testing/examples/refile/b.org
@@ -0,0 +1,6 @@
+* b/1/1
+** b/1/2
+*** b/1/3
+* b/2/1
+** b/2/2
+*** b/2/3
diff --git a/testing/lisp/test-org.el b/testing/lisp/test-org.el
index b8bd88957..81ec378c2 100644
--- a/testing/lisp/test-org.el
+++ b/testing/lisp/test-org.el
@@ -6282,6 +6282,50 @@ (ert-deftest test-org/show-set-visibility ()
      (org-show-set-visibility 'minimal)
      (org-invisible-p2))))
 
+
+;;; org-refile
+
+(ert-deftest test-org/org-refile-get-targets ()
+  "Test `org-refile-get-targets'."
+  (save-window-excursion
+    (let ((examples-dir (file-truename "../examples/refile/")))
+      (cd examples-dir)
+      (find-file-read-only "a.org")
+      (find-file-read-only "b.org")
+      (rename-buffer "gratuitous-prefix/b.org")
+      (let ((org-refile-targets '((("a.org" "b.org") :level . 2)))
+           (testcases
+            `((nil . ("a/1/2"
+                      "a/2/2"
+                      "b/1/2"
+                      "b/2/2"))
+              (file . ("a.org"
+                       "a.org/a\\/1\\/1/a\\/1\\/2"
+                       "a.org/a\\/2\\/1/a\\/2\\/2"
+                       "b.org"
+                       "b.org/b\\/1\\/1/b\\/1\\/2"
+                       "b.org/b\\/2\\/1/b\\/2\\/2"))
+              (full-file-path . ,(mapcar (lambda (s) (concat examples-dir s))
+                                         '("a.org"
+                                           "a.org/a\\/1\\/1/a\\/1\\/2"
+                                           "a.org/a\\/2\\/1/a\\/2\\/2"
+                                           "b.org"
+                                           "b.org/b\\/1\\/1/b\\/1\\/2"
+                                           "b.org/b\\/2\\/1/b\\/2\\/2")))
+              (buffer-name . ("a.org"
+                              "a.org/a\\/1\\/1/a\\/1\\/2"
+                              "a.org/a\\/2\\/1/a\\/2\\/2"
+                              "gratuitous-prefix/b.org"
+                              "gratuitous-prefix/b.org/b\\/1\\/1/b\\/1\\/2"
+                              
"gratuitous-prefix/b.org/b\\/2\\/1/b\\/2\\/2")))))
+       (cl-loop for (use-outline-path . expected-targets) in testcases
+                do (let ((org-refile-use-outline-path use-outline-path))
+                     (should
+                      (equal
+                       (mapcar #'car
+                               (org-refile-get-targets))
+                       expected-targets))))))))
+
 
 (provide 'test-org)
 
-- 
2.13.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]