Move unit tests from ert to buttercup
Easier to organize and write. Now I can hopefully strive for better coverage!
This commit is contained in:
parent
98d2f1de3f
commit
eaca8c58fa
41 changed files with 1371 additions and 1101 deletions
|
@ -1,50 +0,0 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; ui/doom-dashboard/test/doom-dashboard.el
|
||||
|
||||
(require! :ui doom-dashboard)
|
||||
|
||||
(defun -dashboard-test-pwd (spec file)
|
||||
(let ((kill-buffer-query-functions '(+doom-dashboard|reload-on-kill))
|
||||
(+doom-dashboard-pwd-policy (car spec))
|
||||
(fallback-buffer (doom-fallback-buffer))
|
||||
+doom-dashboard--last-cwd
|
||||
projectile-enable-caching)
|
||||
(with-temp-buffer
|
||||
(setq buffer-file-name file
|
||||
default-directory (file-name-directory file)
|
||||
doom-real-buffer-p t))
|
||||
(should +doom-dashboard--last-cwd)
|
||||
(+doom-dashboard-update-pwd)
|
||||
(should (equal (buffer-local-value 'default-directory fallback-buffer)
|
||||
(cdr spec)))))
|
||||
|
||||
;;
|
||||
(def-test! dashboard-p
|
||||
(let ((fallback-buffer (doom-fallback-buffer)))
|
||||
(should (equal (buffer-name fallback-buffer) +doom-dashboard-name))
|
||||
(should (+doom-dashboard-p fallback-buffer))))
|
||||
|
||||
(def-test! get-pwd
|
||||
:minor-mode projectile-mode
|
||||
(let ((default-directory doom-core-dir)
|
||||
(+doom-dashboard--last-cwd doom-core-dir)
|
||||
projectile-enable-caching)
|
||||
(dolist (spec (list (cons 'last-project doom-emacs-dir)
|
||||
(cons 'last doom-core-dir)
|
||||
(cons (lambda (x) "x") "x")
|
||||
(cons "~" (expand-file-name "~"))
|
||||
(cons nil default-directory)))
|
||||
(let ((+doom-dashboard-pwd-policy (car spec)))
|
||||
(should (equal (+doom-dashboard--get-pwd) (cdr spec)))))))
|
||||
|
||||
(def-test! pwd-policy
|
||||
:minor-mode projectile-mode
|
||||
(dolist (spec (list (cons 'last-project doom-emacs-dir)
|
||||
(cons 'last doom-core-dir)
|
||||
(cons "~" (expand-file-name "~/"))
|
||||
(cons (lambda (x) "/tmp") "/tmp/")))
|
||||
(-dashboard-test-pwd spec (expand-file-name "core.el" doom-core-dir))))
|
||||
|
||||
;;
|
||||
(def-test! inhibit-refresh :skip t)
|
||||
(def-test! inhibit-functions :skip t)
|
40
modules/ui/doom-dashboard/test/test-doom-dashboard.el
Normal file
40
modules/ui/doom-dashboard/test/test-doom-dashboard.el
Normal file
|
@ -0,0 +1,40 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; ui/doom-dashboard/test/test-doom-dashboard.el
|
||||
|
||||
(require! :ui doom-dashboard)
|
||||
|
||||
(describe "ui/doom-dashboard"
|
||||
:var (default-directory projectile-enable-caching)
|
||||
(before-all
|
||||
(require 'projectile)
|
||||
(setq projectile-enable-caching nil))
|
||||
(after-all
|
||||
(unload-feature 'projectile t))
|
||||
|
||||
(before-each (projectile-mode +1))
|
||||
(after-each (projectile-mode +1))
|
||||
|
||||
(describe "get-pwd"
|
||||
:var (+doom-dashboard--last-cwd)
|
||||
(before-each
|
||||
(setq +doom-dashboard--last-cwd doom-core-dir
|
||||
default-directory doom-core-dir))
|
||||
(it "returns the current directory when policy is nil"
|
||||
(let (+doom-dashboard-pwd-policy)
|
||||
(expect (+doom-dashboard--get-pwd) :to-equal default-directory)))
|
||||
(it "returns a path if policy is a path"
|
||||
(let ((+doom-dashboard-pwd-policy "~"))
|
||||
(expect (+doom-dashboard--get-pwd) :to-equal (expand-file-name "~"))))
|
||||
(it "returns return value of policy as a function"
|
||||
(let ((+doom-dashboard-pwd-policy (lambda (x) "x")))
|
||||
(expect (+doom-dashboard--get-pwd) :to-equal "x")))
|
||||
(it "returns last cwd if policy is 'last"
|
||||
(let ((+doom-dashboard-pwd-policy 'last))
|
||||
(expect (+doom-dashboard--get-pwd) :to-equal doom-core-dir)))
|
||||
(it "returns last project if policy is 'last-project"
|
||||
(let ((+doom-dashboard-pwd-policy 'last-project))
|
||||
(expect (+doom-dashboard--get-pwd) :to-equal doom-emacs-dir))))
|
||||
|
||||
(describe "dashboard-p"
|
||||
(it "changes the fallback buffer to the dashboard buffer"
|
||||
(expect (+doom-dashboard-p (doom-fallback-buffer))))))
|
Loading…
Add table
Add a link
Reference in a new issue