2017-12-30 01:26:46 -05:00
|
|
|
;; -*- no-byte-compile: t; -*-
|
|
|
|
;;; ../core/test/core-ui.el
|
|
|
|
|
2017-12-31 11:45:02 -05:00
|
|
|
(defmacro with-temp-windows!! (&rest body)
|
2017-12-30 01:26:46 -05:00
|
|
|
(declare (indent defun))
|
2018-01-03 14:29:51 -05:00
|
|
|
`(cl-flet ((split-window (symbol-function #'split-window-horizontally)))
|
2017-12-30 01:26:46 -05:00
|
|
|
(delete-other-windows)
|
2018-01-03 14:29:51 -05:00
|
|
|
(let ((a (get-buffer-create "a"))
|
|
|
|
(b (get-buffer-create "b"))
|
|
|
|
(split-width-threshold 0)
|
|
|
|
(window-min-width 0))
|
|
|
|
,@body)))
|
2017-12-30 01:26:46 -05:00
|
|
|
|
|
|
|
;;
|
|
|
|
(def-test! set-mode-name
|
2018-01-03 14:29:51 -05:00
|
|
|
(let ((after-change-major-mode-hook '(doom|set-mode-name))
|
|
|
|
(doom-major-mode-names '((text-mode . "abc")
|
2017-12-30 01:26:46 -05:00
|
|
|
(lisp-mode . (lambda () "xyz"))
|
|
|
|
(js-mode . t))))
|
2017-12-31 11:45:02 -05:00
|
|
|
(text-mode)
|
|
|
|
(should (equal mode-name "abc"))
|
|
|
|
(lisp-mode)
|
|
|
|
(should (equal mode-name "xyz"))
|
|
|
|
(should-error (js-mode))))
|
2017-12-30 01:26:46 -05:00
|
|
|
|
|
|
|
(def-test! protect-visible-buffers
|
2017-12-31 11:45:02 -05:00
|
|
|
(with-temp-windows!!
|
2017-12-30 01:26:46 -05:00
|
|
|
(let ((kill-buffer-query-functions '(doom|protect-visible-buffers)))
|
|
|
|
(switch-to-buffer a) (split-window)
|
|
|
|
(switch-to-buffer b) (split-window)
|
|
|
|
(switch-to-buffer a)
|
|
|
|
(should-not (kill-buffer))
|
|
|
|
(select-window (get-buffer-window b))
|
|
|
|
(should (kill-buffer)))))
|