be6a4c813b9cab2befa32228ddf9f0c45333796a — Kisaragi Hiu 5 months ago b19fb82 master
add limited test suite
1 files changed, 80 insertions(+), 0 deletions(-)

A yabookmark-test.el
A yabookmark-test.el => yabookmark-test.el +80 -0
@@ 0,0 1,80 @@
+;;; yabookmark-test.el --- tests for yabookmark -*- lexical-binding: t -*-
+
+;; Author: Kisaragi Hiu
+;; Maintainer: Kisaragi Hiu
+
+
+;; This file is not part of GNU Emacs
+
+;; This file is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation; either version 3, or (at your option)
+;; any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;; GNU General Public License for more details.
+
+;; For a full copy of the GNU General Public License
+;; see <http://www.gnu.org/licenses/>.
+
+
+;;; Commentary:
+
+;; Tests. Some may be manual.
+
+;;; Code:
+(require 'yabookmark)
+(require 'buttercup)
+
+(let ((bm (make-yabookmark-bookmark :name "notes.org"
+                                    :path (f-join
+                                           kisaragi/notes-directory
+                                           "notes.org")
+                                    :position 300)))
+  (yabookmark-jump bm))
+
+(yabookmark-bookmark-equal-p
+ (make-yabookmark-bookmark :name "notes.org"
+                           :position 300)
+ (make-yabookmark-bookmark :name "notes.org"
+                           :position 300))
+
+(yabookmark-bookmark-equal-p
+ (make-yabookmark-bookmark :name "notes.org"
+                           :position 400)
+ (make-yabookmark-bookmark :name "notes.org"
+                           :position 300))
+
+(yabookmark-bookmark-equal-p
+ (make-yabookmark-bookmark :name "otes.org"
+                           :position 300)
+ (make-yabookmark-bookmark :name "notes.org"
+                           :position 300))
+
+(yabookmark-bookmark-equal-p
+ (make-yabookmark-bookmark :name "notes.org" :path "/p/a/t/h")
+ (make-yabookmark-bookmark :name "notes.org" :path "/p/a/t/l"))
+
+(yabookmark-bookmark-equal-p
+ nil
+ (make-yabookmark-bookmark :name "notes.org" :path "/p/a/t/l"))
+
+(describe "Collection dedupe"
+  (it "Removes the right items"
+    (expect
+     (yabookmark-collection-dedupe
+      `(,(make-yabookmark-bookmark :name "notes.org" :path "/p/a/t/l")
+        ,(make-yabookmark-bookmark :name "notes.org" :path "/p/a/t/l")
+        ,(make-yabookmark-bookmark :name "notes.org" :path "/p/a/t/l" :position 30)
+        ,(make-yabookmark-bookmark :name ".org" :path "/p/a/t/h" :position 30)
+        ,(make-yabookmark-bookmark :name "another.org" :path "/p/a/t/h" :position 30)))
+     :to-equal
+      `(,(make-yabookmark-bookmark :name "notes.org" :path "/p/a/t/l")
+        ,(make-yabookmark-bookmark :name "notes.org" :path "/p/a/t/l" :position 30)
+        ,(make-yabookmark-bookmark :name ".org" :path "/p/a/t/h" :position 30)
+        ,(make-yabookmark-bookmark :name "another.org" :path "/p/a/t/h" :position 30)))))
+
+(provide 'yabookmark-test)
+;;; yabookmark-test.el ends here