Skip to content

Commit abc4d3a

Browse files
committed
Refactor tests
1 parent b0d0b7c commit abc4d3a

1 file changed

Lines changed: 12 additions & 41 deletions

File tree

test/magit-standup-test.el

Lines changed: 12 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,18 @@
1010
(require 'magit-standup)
1111

1212
(describe "magit-standup--since-date"
13-
(it "looks back 3 days on Monday (to Friday)"
14-
;; Monday 2026-01-05 12:00:00 UTC — %u = 1
15-
(let ((magit-standup-since-days-ago nil))
16-
(cl-letf (((symbol-function 'current-time)
17-
(lambda () (encode-time 0 0 12 5 1 2026))))
18-
(expect (magit-standup--since-date) :to-equal "2026-01-02"))))
19-
20-
(it "looks back 1 day on Tuesday"
21-
;; Tuesday 2026-01-06 12:00:00 UTC — %u = 2
22-
(let ((magit-standup-since-days-ago nil))
23-
(cl-letf (((symbol-function 'current-time)
24-
(lambda () (encode-time 0 0 12 6 1 2026))))
25-
(expect (magit-standup--since-date) :to-equal "2026-01-05"))))
26-
27-
(it "looks back 1 day on Wednesday"
28-
;; Wednesday 2026-01-07 12:00:00 UTC — %u = 3
29-
(let ((magit-standup-since-days-ago nil))
30-
(cl-letf (((symbol-function 'current-time)
31-
(lambda () (encode-time 0 0 12 7 1 2026))))
32-
(expect (magit-standup--since-date) :to-equal "2026-01-06"))))
33-
34-
(it "looks back to Friday on Saturday (1 day)"
35-
;; Saturday 2026-01-10 12:00:00 UTC — %u = 6
36-
(let ((magit-standup-since-days-ago nil))
37-
(cl-letf (((symbol-function 'current-time)
38-
(lambda () (encode-time 0 0 12 10 1 2026))))
39-
(expect (magit-standup--since-date) :to-equal "2026-01-09"))))
40-
41-
(it "looks back to Friday on Sunday (2 days)"
42-
;; Sunday 2026-01-11 12:00:00 UTC — %u = 7
43-
(let ((magit-standup-since-days-ago nil))
44-
(cl-letf (((symbol-function 'current-time)
45-
(lambda () (encode-time 0 0 12 11 1 2026))))
46-
(expect (magit-standup--since-date) :to-equal "2026-01-09"))))
47-
48-
(it "uses custom override when magit-standup-since-days-ago is set"
49-
;; Wednesday 2026-01-07 — would normally be 1 day back
50-
(let ((magit-standup-since-days-ago 7))
51-
(cl-letf (((symbol-function 'current-time)
52-
(lambda () (encode-time 0 0 12 7 1 2026))))
53-
(expect (magit-standup--since-date) :to-equal "2025-12-31")))))
13+
(dolist (case '((:desc "looks back 3 days on Monday (to Friday)" :date "2026-01-05" :expected "2026-01-02")
14+
(:desc "looks back 1 day on Tuesday" :date "2026-01-06" :expected "2026-01-05")
15+
(:desc "looks back 1 day on Wednesday" :date "2026-01-07" :expected "2026-01-06")
16+
(:desc "looks back to Friday on Saturday (1 day)" :date "2026-01-10" :expected "2026-01-09")
17+
(:desc "looks back to Friday on Sunday (2 days)" :date "2026-01-11" :expected "2026-01-09")
18+
(:desc "uses custom override when set" :date "2026-01-07" :expected "2025-12-31" :override 7)))
19+
(it (plist-get case :desc)
20+
(let ((magit-standup-since-days-ago (plist-get case :override))
21+
(current-time (date-to-time (concat (plist-get case :date) " 12:00:00"))))
22+
(cl-letf (((symbol-function 'current-time)
23+
(lambda () current-time)))
24+
(expect (magit-standup--since-date) :to-equal (plist-get case :expected)))))))
5425

5526
(describe "magit-standup--detect-link-package"
5627
(it "returns orgit when orgit is loaded"

0 commit comments

Comments
 (0)