-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmistilteinn-test.el
97 lines (92 loc) · 3.23 KB
/
mistilteinn-test.el
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
;; -*- coding: utf-8 -*-
;;; mistilteinn-test.el ---
(require 'mistilteinn)
(require 'el-expectations)
(require 'el-mock)
(dont-compile
(when (fboundp 'expectations)
(expectations
(desc "mistilteinn inside")
(expect t
(mi:inside-p "."))
(expect nil
(mi:inside-p "/"))
(desc "command: git-now")
(expect (mock (shell-command "git now --compact"))
(mistilteinn-git-now))
(desc "command: git-master")
(expect (mock (shell-command "git master master"))
(stub completing-read => "master")
(mistilteinn-git-master))
(desc "command: mistilteinn create")
(expect (mock (shell-command "mistilteinn create \"ticket title\""))
(mistilteinn-git-ticket-create "ticket title"))
(desc "command: git-now --fixup")
(expect (mock (shell-command "git now --fixup \"ticket\""))
(mi:git-fixup "ticket"))
(desc "command: git-now --diff")
(expect (mock (shell-command "git now --diff" "buf"))
(mi:git-diff "buf"))
(desc "message buffer: close-message-buffer should kill current buffer")
(expect nil
(let ((buffer (generate-new-buffer "test")))
(with-current-buffer buffer
(mi:close-message-buffer)
(buffer-live-p buffer))))
(desc "message buffer: strip comment")
(expect "bar\n"
(mi:strip-comment "# foo
bar
# baz
")
)
(desc "message buffer: keymap")
(expect 'mi:close-message-buffer
(lookup-key mi:message-keymap (kbd "C-c C-q")))
(expect 'mi:commit-message-buffer
(lookup-key mi:message-keymap (kbd "C-c C-c")))
(desc "message buffer: callback after commit messeage")
(expect (mock (callback "foobar
"))
(mi:show-message-buffer 'callback)
(insert "foobar")
(mi:commit-message-buffer))
(desc "message buffer: buffer")
(expect mistilteinn-message-buffer
(mi:show-message-buffer '(lambda (s)))
(prog1
(buffer-name)
(mi:close-message-buffer)))
(expect nil
(mi:show-message-buffer '(lambda (s)))
(let ((buffer (current-buffer)))
(mi:close-message-buffer)
(buffer-live-p buffer)))
(expect nil
(mi:show-message-buffer '(lambda (s)))
(let ((buffer (current-buffer)))
(mi:commit-message-buffer)
(buffer-live-p buffer)))
(desc "git util")
(expect '("foo" "bar" "baz" "master")
(stub shell-command-to-string => " foo
* bar
baz
master
")
(mi:branch-list))
(desc "mi:close-message-buffer")
(expect (mock (kill-buffer *))
(mi:close-message-buffer))
(desc "mi:switch-topic-branch")
(expect (mock (shell-command "git branch id/100 2>/dev/null; git checkout id/100"))
(mi:switch-topic-branch "100"))
(desc "highlight a resolved ticket inactive")
(expect 'mistilteinn-inactive-ticket-face
(get-text-property 1 'face (car (mi:highlight-ticket '("[解決] id/100")))))
(desc "highlight a unresolved ticket active")
(expect 'mistilteinn-active-ticket-face
(get-text-property 1 'face (car (mi:highlight-ticket '("id/100")))))
)))
(provide 'mistilteinn-test)
;;; mistilteinn-test.el ends here