]> git.eshelyaron.com Git - emacs.git/commitdiff
Add more tests for bookmark-bmenu-list
authorStefan Kangas <stefankangas@gmail.com>
Sun, 26 Jan 2020 03:08:33 +0000 (04:08 +0100)
committerStefan Kangas <stefankangas@gmail.com>
Sun, 26 Jan 2020 03:11:38 +0000 (04:11 +0100)
* test/lisp/bookmark-tests.el (cl-lib): Require.
(bookmark-test-bmenu-toggle-filenames)
(bookmark-test-bmenu-toggle-filenames/show)
(bookmark-test-bmenu-show-filenames)
(bookmark-test-bmenu-hide-filenames)
(bookmark-test-bmenu-bookmark, bookmark-test-bmenu-mark)
(bookmark-test-bmenu-any-marks, bookmark-test-bmenu-unmark)
(bookmark-test-bmenu-delete, bookmark-test-bmenu-locate): New
tests.

(bookmark-test-bmenu-edit-annotation/show-annotation): Rename from
'bookmark-bmenu-edit-annotation/show-annotation'.
(bookmark-test-bmenu-send-edited-annotation): Rename from
'bookmark-bmenu-send-edited-annotation'.
(bookmark-test-bmenu-send-edited-annotation/restore-focus): Rename
from 'bookmark-bmenu-send-edited-annotation/restore-focus'.

test/lisp/bookmark-tests.el

index 7e0384b72416689df019fb54ae1d1f7133e828b2..b9c6ff9c542884b58a918ba135448b67d9f88b13 100644 (file)
@@ -25,6 +25,7 @@
 
 (require 'ert)
 (require 'bookmark)
+(require 'cl-lib)
 
 (defvar bookmark-tests-data-dir
   (file-truename
@@ -339,21 +340,21 @@ testing `bookmark-bmenu-list'."
             ,@body)
         (kill-buffer bookmark-bmenu-buffer)))))
 
-(ert-deftest bookmark-bmenu.enu-edit-annotation/show-annotation ()
+(ert-deftest bookmark-test-bmenu-edit-annotation/show-annotation ()
   (with-bookmark-bmenu-test
    (bookmark-set-annotation "name" "foo")
    (bookmark-bmenu-edit-annotation)
    (should (string-match "foo" (buffer-string)))
    (kill-buffer (current-buffer))))
 
-(ert-deftest bookmark-bmenu-send-edited-annotation ()
+(ert-deftest bookmark-test-bmenu-send-edited-annotation ()
   (with-bookmark-bmenu-test
    (bookmark-bmenu-edit-annotation)
    (insert "foo")
    (bookmark-send-edited-annotation)
    (should (equal (bookmark-get-annotation "name") "foo"))))
 
-(ert-deftest bookmark-bmenu-send-edited-annotation/restore-focus ()
+(ert-deftest bookmark-test-bmenu-send-edited-annotation/restore-focus ()
   "Test for https://debbugs.gnu.org/20150 ."
   (with-bookmark-bmenu-test
    (bookmark-bmenu-edit-annotation)
@@ -362,5 +363,73 @@ testing `bookmark-bmenu-list'."
    (should (equal (buffer-name (current-buffer)) bookmark-bmenu-buffer))
    (should (looking-at "name"))))
 
+(ert-deftest bookmark-test-bmenu-toggle-filenames ()
+  (with-bookmark-bmenu-test
+   (should (re-search-forward "/some/file" nil t))
+   (bookmark-bmenu-toggle-filenames)
+   (goto-char (point-min))
+   (should-not (re-search-forward "/some/file" nil t))))
+
+(ert-deftest bookmark-test-bmenu-toggle-filenames/show ()
+  (with-bookmark-bmenu-test
+   (bookmark-bmenu-toggle-filenames t)
+   (should (re-search-forward "/some/file"))))
+
+(ert-deftest bookmark-test-bmenu-show-filenames ()
+  (with-bookmark-bmenu-test
+   (bookmark-bmenu-show-filenames)
+   (should (re-search-forward "/some/file"))))
+
+(ert-deftest bookmark-test-bmenu-hide-filenames ()
+  (with-bookmark-bmenu-test
+   (bookmark-bmenu-hide-filenames)
+   (goto-char (point-min))
+   (should-not (re-search-forward "/some/file" nil t))))
+
+(ert-deftest bookmark-test-bmenu-bookmark ()
+  (with-bookmark-bmenu-test
+   (should (equal (bookmark-bmenu-bookmark) "name"))))
+
+(ert-deftest bookmark-test-bmenu-mark ()
+  (with-bookmark-bmenu-test
+   (bookmark-bmenu-mark)
+   (beginning-of-line)
+   (should (looking-at "^>"))))
+
+(ert-deftest bookmark-test-bmenu-any-marks ()
+  (with-bookmark-bmenu-test
+   (bookmark-bmenu-mark)
+   (beginning-of-line)
+   (should (bookmark-bmenu-any-marks))))
+
+(ert-deftest bookmark-test-bmenu-unmark ()
+  (with-bookmark-bmenu-test
+   (bookmark-bmenu-mark)
+   (goto-char (point-min))
+   (bookmark-bmenu-unmark)
+   (beginning-of-line)
+   (should (looking-at "^  "))))
+
+(ert-deftest bookmark-test-bmenu-delete ()
+  (with-bookmark-bmenu-test
+   (bookmark-bmenu-delete)
+   (bookmark-bmenu-execute-deletions)
+   (should (equal (length bookmark-alist) 0))))
+
+(ert-deftest bookmark-test-bmenu-locate ()
+  (let (msg)
+    (cl-letf (((symbol-function 'message)
+               (lambda (&rest args)
+                 (setq msg (apply #'format args)))))
+      (with-bookmark-bmenu-test
+       (bookmark-bmenu-locate)
+       (should (equal msg "/some/file"))))))
+
+(ert-deftest bookmark-test-bmenu-filter-alist-by-regexp ()
+  (with-bookmark-bmenu-test
+   (bookmark-bmenu-filter-alist-by-regexp regexp-unmatchable)
+   (goto-char (point-min))
+   (should (looking-at "^$"))))
+
 (provide 'bookmark-tests)
 ;;; bookmark-tests.el ends here