2018-06-15 03:31:54 +02:00
|
|
|
;; -*- no-byte-compile: t; -*-
|
|
|
|
;;; ui/doom-dashboard/test/test-doom-dashboard.el
|
|
|
|
|
2018-08-25 23:47:31 +02:00
|
|
|
(require 'core-projects)
|
|
|
|
(require 'projectile)
|
|
|
|
(require! :ui doom-dashboard)
|
|
|
|
|
2018-06-15 03:31:54 +02:00
|
|
|
(describe "ui/doom-dashboard"
|
|
|
|
:var (default-directory projectile-enable-caching)
|
2019-04-08 23:15:22 -04:00
|
|
|
(before-all
|
|
|
|
(setq projectile-enable-caching nil
|
|
|
|
doom-fallback-buffer-name +doom-dashboard-name))
|
2018-06-15 03:31:54 +02:00
|
|
|
|
|
|
|
(before-each (projectile-mode +1))
|
2018-07-04 23:14:31 +02:00
|
|
|
(after-each (projectile-mode -1))
|
2018-06-15 03:31:54 +02:00
|
|
|
|
|
|
|
(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))))))
|