Clean up & refactor tests
This commit is contained in:
parent
2b36740325
commit
9108f4780e
|
@ -19,11 +19,23 @@
|
|||
(kill-buffer c)
|
||||
(kill-buffer d))
|
||||
|
||||
(describe "buffer-list"
|
||||
(it "should only see four buffers"
|
||||
(expect (doom-buffer-list) :to-contain-items (list a b c d))))
|
||||
(describe "buffer lists"
|
||||
(describe "doom-buffer-list"
|
||||
(it "should only see four buffers"
|
||||
(expect (doom-buffer-list) :to-contain-items (list a b c d)))))
|
||||
|
||||
(describe "project-buffer-list"
|
||||
;; TODO predicate tests
|
||||
(xdescribe "predicate functions"
|
||||
(describe "doom-dired-buffer-p")
|
||||
(describe "doom-special-buffer-p")
|
||||
(describe "doom-temp-buffer-p")
|
||||
(describe "doom-visible-buffer-p")
|
||||
(describe "doom-buried-buffer-p")
|
||||
(describe "doom-non-file-visiting-buffer-p")
|
||||
(describe "doom-dired-buffer-p")
|
||||
(describe "doom-buffer-frame-predicate"))
|
||||
|
||||
(describe "doom-project-buffer-list"
|
||||
:var (projectile-projects-cache-time projectile-projects-cache)
|
||||
(before-all (require 'projectile))
|
||||
(after-all (unload-feature 'projectile t))
|
||||
|
@ -47,7 +59,7 @@
|
|||
(expect (doom-project-buffer-list)
|
||||
:to-have-same-items-as (buffer-list)))))
|
||||
|
||||
(describe "fallback-buffer"
|
||||
(describe "doom-fallback-buffer"
|
||||
(it "returns a live buffer"
|
||||
(expect (buffer-live-p (doom-fallback-buffer))))
|
||||
|
||||
|
@ -56,12 +68,22 @@
|
|||
|
||||
(describe "real buffers"
|
||||
(before-each
|
||||
(doom-set-buffer-real a t)
|
||||
(with-current-buffer b (setq buffer-file-name "x"))
|
||||
(with-current-buffer c (rename-buffer "*C*")))
|
||||
|
||||
(describe "real-buffer-p"
|
||||
(describe "doom-mark-buffer-as-real-h"
|
||||
(with-current-buffer a
|
||||
(doom-mark-buffer-as-real-h)
|
||||
(expect (buffer-local-value 'doom-real-buffer-p a))))
|
||||
|
||||
(describe "doom-set-buffer-real"
|
||||
(it "sets `doom-real-buffer-p' buffer-locally"
|
||||
(doom-set-buffer-real a t)
|
||||
(expect (buffer-local-value 'doom-real-buffer-p a))))
|
||||
|
||||
(describe "doom-real-buffer-p"
|
||||
(it "returns t for buffers manually marked real"
|
||||
(doom-set-buffer-real a t)
|
||||
(expect (doom-real-buffer-p a)))
|
||||
(it "returns t for file-visiting buffers"
|
||||
(expect (doom-real-buffer-p b)))
|
||||
|
@ -69,7 +91,16 @@
|
|||
(expect (doom-real-buffer-p c) :to-be nil)
|
||||
(expect (doom-real-buffer-p d) :to-be nil)))
|
||||
|
||||
(describe "real-buffer-list"
|
||||
(describe "doom-unreal-buffer-p"
|
||||
(it "returns t for unreal buffers"
|
||||
(expect (doom-unreal-buffer-p c))
|
||||
(expect (doom-unreal-buffer-p d)))
|
||||
(it "returns nil for real buffers"
|
||||
(doom-set-buffer-real a t)
|
||||
(expect (not (doom-unreal-buffer-p a)))
|
||||
(expect (not (doom-unreal-buffer-p b)))))
|
||||
|
||||
(describe "doom-real-buffer-list"
|
||||
(it "returns only real buffers"
|
||||
(expect (doom-real-buffer-list) :to-contain-items (list a b)))))
|
||||
|
||||
|
@ -82,36 +113,48 @@
|
|||
(split-window)
|
||||
(switch-to-buffer b))
|
||||
|
||||
(it "can match buffers by regexp"
|
||||
(expect (doom-matching-buffers "^[ac]$") :to-have-same-items-as (list a c)))
|
||||
(describe "doom-matching-buffers"
|
||||
(it "can match buffers by regexp"
|
||||
(expect (doom-matching-buffers "^[ac]$") :to-have-same-items-as (list a c))))
|
||||
|
||||
(it "can match buffers by major-mode"
|
||||
(expect (doom-buffers-in-mode 'text-mode) :to-have-same-items-as (list b c)))
|
||||
(describe "doom-buffers-in-mode"
|
||||
(it "can match buffers by major-mode"
|
||||
(expect (doom-buffers-in-mode 'text-mode) :to-have-same-items-as (list b c))))
|
||||
|
||||
(it "can find all buried buffers"
|
||||
(expect (doom-buried-buffers) :to-contain-items (list c d)))
|
||||
(describe "doom-buried-buffers"
|
||||
(it "can find all buried buffers"
|
||||
(expect (doom-buried-buffers) :to-contain-items (list c d))))
|
||||
|
||||
(it "can find all visible buffers"
|
||||
(expect (doom-visible-buffers)
|
||||
:to-have-same-items-as (list a b)))
|
||||
(describe "doom-visible-buffers"
|
||||
(it "can find all visible buffers"
|
||||
(expect (doom-visible-buffers)
|
||||
:to-have-same-items-as (list a b))))
|
||||
|
||||
(it "can find all visible windows"
|
||||
(expect (doom-visible-windows)
|
||||
:to-have-same-items-as
|
||||
(mapcar #'get-buffer-window (list a b)))))
|
||||
(describe "doom-visible-windows"
|
||||
(it "can find all visible windows"
|
||||
(expect (doom-visible-windows)
|
||||
:to-have-same-items-as
|
||||
(mapcar #'get-buffer-window (list a b))))))
|
||||
|
||||
(describe "kill-buffer-and-windows"
|
||||
(before-each
|
||||
(split-window) (switch-to-buffer b)
|
||||
(split-window) (switch-to-buffer a))
|
||||
(describe "killing buffers/windows"
|
||||
(describe "doom-kill-buffer-and-windows"
|
||||
(before-each
|
||||
(split-window) (switch-to-buffer b)
|
||||
(split-window) (switch-to-buffer a))
|
||||
|
||||
(it "kills the selected buffers and all its windows"
|
||||
(doom-kill-buffer-and-windows a)
|
||||
(expect (buffer-live-p a) :to-be nil)
|
||||
(expect (length (doom-visible-windows)) :to-be 1)))
|
||||
(it "kills the selected buffers and all its windows"
|
||||
(doom-kill-buffer-and-windows a)
|
||||
(expect (buffer-live-p a) :to-be nil)
|
||||
(expect (length (doom-visible-windows)) :to-be 1)))
|
||||
|
||||
;; TODO
|
||||
(xdescribe "kill-all-buffers")
|
||||
(xdescribe "kill-other-buffers")
|
||||
(xdescribe "kill-matching-buffers")
|
||||
(xdescribe "cleanup-session")))
|
||||
;; TODO
|
||||
(xdescribe "doom-fixup-windows")
|
||||
(xdescribe "doom-kill-buffer-fixup-windows")
|
||||
(xdescribe "doom-kill-buffers-fixup-windows"))
|
||||
|
||||
(xdescribe "commands"
|
||||
(describe "doom/kill-all-buffers")
|
||||
(describe "doom/kill-other-buffers")
|
||||
(describe "doom/kill-matching-buffers")
|
||||
(describe "doom/kill-buried-buffers")
|
||||
(describe "doom/kill-project-buffers"))))
|
||||
|
|
|
@ -5,11 +5,6 @@
|
|||
|
||||
(load! "autoload/files" doom-core-dir)
|
||||
|
||||
(xdescribe "doom-glob")
|
||||
(xdescribe "doom-path")
|
||||
(xdescribe "doom-dir")
|
||||
(xdescribe "doom-files-in")
|
||||
|
||||
(describe "library"
|
||||
(describe "file-exists-p!"
|
||||
(it "is a (quasi) drop-in replacement for `file-exists-p'"
|
||||
|
@ -96,7 +91,16 @@
|
|||
(getfilename))
|
||||
"LICENSE")
|
||||
doom-emacs-dir)
|
||||
:to-equal (expand-file-name "LICENSE" doom-emacs-dir))))))
|
||||
:to-equal (expand-file-name "LICENSE" doom-emacs-dir)))))
|
||||
|
||||
;; TODO
|
||||
(xdescribe "doom-glob")
|
||||
(xdescribe "doom-path")
|
||||
(xdescribe "doom-dir")
|
||||
(xdescribe "doom-files-in")
|
||||
(xdescribe "doom-file-size")
|
||||
(xdescribe "doom-directory-size")
|
||||
(xdescribe "doom-file-cookie-p"))
|
||||
|
||||
(describe "interactive file operations"
|
||||
:var (src dest projectile-projects-cache-time projectile-projects-cache)
|
||||
|
@ -149,4 +153,12 @@
|
|||
(expect (file-exists-p existing) :to-be nil))
|
||||
(it "prompts to delete any existing file"
|
||||
(quiet! (doom/delete-this-file existing))
|
||||
(expect 'y-or-n-p :to-have-been-called-times 1)))))
|
||||
(expect 'y-or-n-p :to-have-been-called-times 1))))
|
||||
|
||||
(xdescribe "sudo {this,find} file"
|
||||
(before-each
|
||||
(spy-on 'find-file :and-return-value nil)
|
||||
(spy-on 'find-alternate-file :and-return-value nil))
|
||||
|
||||
(describe "doom/sudo-find-file")
|
||||
(describe "doom/sudo-this-file")))
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
(describe "core/keybinds"
|
||||
(require 'core-keybinds)
|
||||
|
||||
;; FIXME test against their side effects rather than their implementation
|
||||
(describe "map!"
|
||||
:var (doom--map-evil-p states-alist)
|
||||
(before-each
|
||||
|
|
|
@ -1,7 +1,23 @@
|
|||
;; -*- no-byte-compile: t; -*-
|
||||
;;; core/test/test-core-modules.el
|
||||
;;;###if nil
|
||||
|
||||
;; (require 'core-modules)
|
||||
(xdescribe "core-modules"
|
||||
(require 'core-modules)
|
||||
|
||||
(xdescribe "core-modules")
|
||||
(describe "doom!")
|
||||
(describe "doom-modules")
|
||||
|
||||
(describe "doom-module-p")
|
||||
(describe "doom-module-get")
|
||||
(describe "doom-module-put")
|
||||
(describe "doom-module-set")
|
||||
(describe "doom-module-path")
|
||||
(describe "doom-module-locate-path")
|
||||
(describe "doom-module-from-path")
|
||||
(describe "doom-module-load-path")
|
||||
|
||||
(describe "require!")
|
||||
(describe "featurep!")
|
||||
(describe "after!")
|
||||
(describe "use-package!")
|
||||
(describe "use-package-hook!"))
|
||||
|
|
|
@ -21,14 +21,14 @@
|
|||
|
||||
(describe "project-root"
|
||||
(it "should resolve to the project's root"
|
||||
(expect (doom-project-root doom-core-dir) :to-equal doom-emacs-dir))
|
||||
(expect (doom-project-root doom-core-dir) :to-equal-file doom-emacs-dir))
|
||||
(it "should return nil if not in a project"
|
||||
(expect (doom-project-root (expand-file-name "~")) :to-be nil)))
|
||||
|
||||
(describe "project-expand"
|
||||
(it "expands to a path relative to the project root"
|
||||
(expect (doom-project-expand "init.el" doom-core-dir)
|
||||
:to-equal (expand-file-name "init.el" (doom-project-root doom-core-dir)))))
|
||||
(expect (doom-project-expand "init.el" doom-core-dir) :to-equal-file
|
||||
(expand-file-name "init.el" (doom-project-root doom-core-dir)))))
|
||||
|
||||
(describe "project-file-exists-p!"
|
||||
(let ((default-directory doom-core-dir))
|
||||
|
|
|
@ -76,9 +76,7 @@
|
|||
:var (doom-autoload-file doom-alt-autoload-file result)
|
||||
(before-each
|
||||
(setq doom-autoload-file (make-temp-file "doom-autoload" nil ".el"))
|
||||
(with-temp-file doom-autoload-file
|
||||
(insert "(eval-when-compile (defvar x 1))")
|
||||
(insert "(defvar x 2)"))
|
||||
(with-temp-file doom-autoload-file)
|
||||
(byte-compile-file doom-autoload-file))
|
||||
(after-each
|
||||
(delete-file doom-autoload-file)
|
||||
|
|
Loading…
Reference in New Issue
Block a user