blob: c6fef40650a648661ce69d47891cbf02e54b6ceb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
;;; cider-overlay-tests.el -*- lexical-binding: t; -*-
;; Copyright (C) 2015 Artur Malabarba
;; Author: Artur Malabarba <bruce.connor.am@gmail.com>
;; This program 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 of the License, 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.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
;;; Code:
(require 'ert)
(require 'cider-overlays)
(ert-deftest cider--make-result-overlay ()
;; First, just don't error.
(with-temp-buffer
(insert "garbage")
(save-excursion (insert "\nmore trash"))
(cider--make-result-overlay "ok")
(should (overlays-at (point-min)))
;; Then do some tests.
(mapc #'cider--delete-overlay (overlays-at (point-min)))
(let ((o1 (remove nil (mapcar #'overlay-start
(overlays-at (point-min))))))
(should-not o1))
;; Duration
(cider--make-result-overlay "ok" :duration 'command)
(run-hooks 'post-command-hook)
(run-hooks 'post-command-hook)
(let ((o2 (remove nil (mapcar #'overlay-start
(overlays-at (point-min))))))
(should-not o2))
(let ((this-command nil))
(cider--make-result-overlay "ok" :duration 'command))
(run-hooks 'post-command-hook)
(let ((o3 (remove nil (mapcar #'overlay-start
(overlays-at (point-min))))))
(should-not o3))
(cider--make-result-overlay "ok" :duration 1.5)
(sleep-for 1)
(let ((o4 (remove nil (mapcar #'overlay-start
(overlays-at (point-min))))))
(should o4))
(sleep-for 1)
(let ((o5 (remove nil (mapcar #'overlay-start
(overlays-at (point-min))))))
(should-not o5))))
(provide 'cider-overlay-tests)
;;; cider-overlay-tests.el ends here
|