|
12 | 12 | (stub dashboard-project-status-insert-heading) |
13 | 13 | (stub dashboard-project-status-insert-body) |
14 | 14 | (funcall (dashboard-project-status "foo") nil)) |
| 15 | + |
15 | 16 | (desc "dashboard-project-status with non-nil UPDATE value") |
16 | 17 | (expect (mock (git-run "remote" "update") => nil) |
17 | 18 | (stub dashboard-project-status-insert-heading) |
18 | 19 | (stub dashboard-project-status-insert-body) |
19 | 20 | (funcall (dashboard-project-status "foo" t) nil)) |
| 21 | + |
20 | 22 | (desc "dashboard-project-status inserts a heading") |
21 | 23 | (expect (mock (dashboard-project-status-insert-heading) => nil) |
22 | 24 | (stub dashboard-project-status-insert-body) |
23 | 25 | (funcall (dashboard-project-status "foo") nil)) |
| 26 | + |
24 | 27 | (desc "dashboard-project-status inserts a body") |
25 | | - (expect (mock (dashboard-project-status-insert-body) => nil) |
| 28 | + (expect (mock (dashboard-project-status-insert-body 7) => nil) |
26 | 29 | (stub dashboard-project-status-insert-heading) |
27 | | - (funcall (dashboard-project-status "foo") nil)) |
| 30 | + (funcall (dashboard-project-status "foo") 7)) |
| 31 | + |
28 | 32 | (desc "dashboard-project-status-insert-heading when magit is present inserts status text") |
29 | 33 | ;; the blank in the middle is where the widget should go, |
30 | 34 | ;; but I cannot as yet figure out a way to test that |
|
36 | 40 | (mocklet (((functionp 'magit-status) => t)) |
37 | 41 | (dashboard-project-status-insert-heading))) |
38 | 42 | (buffer-string))) |
| 43 | + |
39 | 44 | (desc "dashboard-project-status-insert-heading when magit is not present only inserts text") |
40 | 45 | (expect "Project foo is up-to-date." |
41 | 46 | (stub dashboard-project-status-git-local-is-behind?) |
|
44 | 49 | (mocklet (((functionp 'magit-status))) |
45 | 50 | (dashboard-project-status-insert-heading))) |
46 | 51 | (buffer-string))) |
| 52 | + |
47 | 53 | (desc "dashboard-project-status-insert-body inserts nothing when no items") |
48 | 54 | (expect "" |
49 | 55 | (stub git-untracked-files) |
50 | 56 | (stub dashboard-project-status-git-unstaged-files) |
51 | 57 | (stub git-staged-files) |
52 | 58 | (with-temp-buffer |
53 | | - (dashboard-project-status-insert-body) |
| 59 | + (dashboard-project-status-insert-body 5) |
54 | 60 | (buffer-string))) |
| 61 | + |
55 | 62 | (desc "dashboard-project-status-insert-body inserts untracked files") |
56 | 63 | (expect (concat "\nUntracked Files:" |
57 | 64 | "\n " |
|
69 | 76 | (let ((git-repo "foo")) |
70 | 77 | (flet ((widget-create (&rest args) |
71 | 78 | (insert (car (last args))))) |
72 | | - (dashboard-project-status-insert-body))) |
| 79 | + (dashboard-project-status-insert-body 5))) |
73 | 80 | (buffer-string))) |
| 81 | + |
74 | 82 | (desc "dashboard-project-status-insert-body inserts unstaged files") |
75 | 83 | (expect (concat "\nUnstaged Files:" |
76 | 84 | "\n " |
|
88 | 96 | (let ((git-repo "foo")) |
89 | 97 | (flet ((widget-create (&rest args) |
90 | 98 | (insert (car (last args))))) |
91 | | - (dashboard-project-status-insert-body))) |
| 99 | + (dashboard-project-status-insert-body 5))) |
92 | 100 | (buffer-string))) |
| 101 | + |
93 | 102 | (desc "dashboard-project-status-insert-body inserts staged files") |
94 | 103 | (expect (concat "\nStaged Files:" |
95 | 104 | "\n " |
|
107 | 116 | (let ((git-repo "foo")) |
108 | 117 | (flet ((widget-create (&rest args) |
109 | 118 | (insert (car (last args))))) |
110 | | - (dashboard-project-status-insert-body))) |
| 119 | + (dashboard-project-status-insert-body 5))) |
| 120 | + (buffer-string))) |
| 121 | + |
| 122 | + (desc "dashboard-project-status-insert-body observes limit") |
| 123 | + (expect (concat "\nUntracked Files:" |
| 124 | + "\n " |
| 125 | + (abbreviate-file-name |
| 126 | + (expand-file-name |
| 127 | + (concat (file-name-as-directory "foo") "foo"))) |
| 128 | + "\n " |
| 129 | + (abbreviate-file-name |
| 130 | + (expand-file-name |
| 131 | + (concat (file-name-as-directory "foo") "bar"))) |
| 132 | + "\nUnstaged Files:" |
| 133 | + "\n " |
| 134 | + (abbreviate-file-name |
| 135 | + (expand-file-name |
| 136 | + (concat (file-name-as-directory "foo") "foo"))) |
| 137 | + "\n " |
| 138 | + (abbreviate-file-name |
| 139 | + (expand-file-name |
| 140 | + (concat (file-name-as-directory "foo") "bar"))) |
| 141 | + "\nStaged Files:" |
| 142 | + "\n " |
| 143 | + (abbreviate-file-name |
| 144 | + (expand-file-name |
| 145 | + (concat (file-name-as-directory "foo") "foo")))) |
| 146 | + (stub git-untracked-files => '("foo" "bar")) |
| 147 | + (stub dashboard-project-status-git-unstaged-files => '("foo" "bar")) |
| 148 | + (stub git-staged-files => '("foo" "bar")) |
| 149 | + (with-temp-buffer |
| 150 | + (let ((git-repo "foo")) |
| 151 | + (flet ((widget-create (&rest args) |
| 152 | + (insert (car (last args))))) |
| 153 | + (dashboard-project-status-insert-body 5))) |
111 | 154 | (buffer-string))) |
| 155 | + |
112 | 156 | (desc "dashboard-project-status-git-local-is-behind? returns non nil when branch is behind") |
113 | 157 | (expect t |
114 | 158 | (mock (git-run "status" "-uno") => "Your branch is behind") |
115 | 159 | (dashboard-project-status-git-local-is-behind?)) |
| 160 | + |
116 | 161 | (desc "dashboard-project-status-git-local-is-behind? returns nil when branch is not behind") |
117 | 162 | (expect nil |
118 | 163 | (mock (git-run "status" "-uno") => "") |
119 | 164 | (dashboard-project-status-git-local-is-behind?)) |
| 165 | + |
120 | 166 | (desc "dashboard-project-status-git-unstaged-files returns a list of unstaged files") |
121 | 167 | (expect '("foo" "bar") |
122 | 168 | (mock (git-run "diff" "--name-only") => "foo\nbar") |
|
0 commit comments