|
1 | | -(import testament :prefix "" :exit true) |
| 1 | +(use judge) |
| 2 | + |
2 | 3 | (import ../../src/date :as "d") |
3 | 4 | (import ../../src/day) |
4 | 5 | (import ../../src/plan) |
|
7 | 8 | ## ————————————————————————————————————————————————————————————————————————————————————————————————— |
8 | 9 | ## Test insert-days |
9 | 10 |
|
10 | | -(deftest insert-day-at-top |
| 11 | +(deftest "insert day at the top" |
11 | 12 | (def plan (plan/build-plan :days @[(day/build-day (d/date 2020 8 3)) |
12 | 13 | (day/build-day (d/date 2020 8 2))])) |
13 | 14 | (def new-plan (insert-days plan (d/date 2020 8 4) (d/date 2020 8 4))) |
14 | 15 | (def day-1 (first (new-plan :days))) |
15 | | - (is (= 3 (length (new-plan :days)))) |
16 | | - (is (= (d/date 2020 8 4) (day-1 :date))) |
17 | | - (is (empty? (day-1 :tasks)))) |
| 16 | + (test (length (new-plan :days)) 3) |
| 17 | + (test (day-1 :date) |
| 18 | + {:day 4 :month 8 :week-day "Tuesday" :year 2020}) |
| 19 | + (test (empty? (day-1 :tasks)) true)) |
18 | 20 |
|
19 | | -(deftest insert-three-days-at-top |
20 | | - (print "insert-three-days-at-top") |
| 21 | +(deftest "insert three days at the top" |
21 | 22 | (def plan (plan/build-plan :days @[(day/build-day (d/date 2020 8 3)) |
22 | 23 | (day/build-day (d/date 2020 8 2))])) |
23 | 24 | (def new-plan (insert-days plan (d/date 2020 8 7) (d/date 2020 8 5))) |
24 | 25 | (def day-1 (first (new-plan :days))) |
25 | | - (is (= 5 (length (new-plan :days)))) |
26 | | - (is (= (d/date 2020 8 7) (day-1 :date)))) |
| 26 | + (test (length (new-plan :days)) 5) |
| 27 | + (test (day-1 :date) |
| 28 | + {:day 7 :month 8 :week-day "Friday" :year 2020})) |
27 | 29 |
|
28 | | -(deftest insert-days-in-middle |
| 30 | +(deftest "insert days in the middle" |
29 | 31 | (def plan (plan/build-plan :days @[(day/build-day (d/date 2020 8 6)) |
30 | 32 | (day/build-day (d/date 2020 8 2))])) |
31 | 33 | (def new-plan (insert-days plan (d/date 2020 8 4) (d/date 2020 8 4))) |
32 | 34 | (def day-2 ((new-plan :days) 1)) |
33 | | - (is (= 3 (length (new-plan :days)))) |
34 | | - (is (= (d/date 2020 8 4) (day-2 :date)))) |
| 35 | + (test (length (new-plan :days)) 3) |
| 36 | + (test (day-2 :date) |
| 37 | + {:day 4 :month 8 :week-day "Tuesday" :year 2020})) |
35 | 38 |
|
36 | | -(deftest insert-days-when-today-already-exists |
| 39 | +(deftest "insert days when today already exists" |
37 | 40 | (def plan (plan/build-plan :days @[(day/build-day (d/date 2020 8 6)) |
38 | 41 | (day/build-day (d/date 2020 8 4))])) |
39 | 42 | (def new-plan (insert-days plan (d/date 2020 8 6) (d/date 2020 8 4))) |
40 | 43 | (def day-2 ((new-plan :days) 1)) |
41 | | - (is (= 3 (length (new-plan :days)))) |
42 | | - (is (= (d/date 2020 8 5) (day-2 :date)))) |
| 44 | + (test (length (new-plan :days)) 3) |
| 45 | + (test (day-2 :date) |
| 46 | + {:day 5 :month 8 :week-day "Wednesday" :year 2020})) |
43 | 47 |
|
44 | | -(deftest insert-days-with-empty-todo |
| 48 | +(deftest "insert days with empty todo" |
45 | 49 | (def plan (plan/build-plan)) |
46 | 50 | (def new-plan (insert-days plan (d/date 2020 8 4) (d/date 2020 8 4))) |
47 | | - (is (= 1 (length (new-plan :days)))) |
48 | | - (is (= (d/date 2020 8 4) ((first (new-plan :days)) :date)))) |
| 51 | + (test (length (new-plan :days)) 1) |
| 52 | + (test ((first (new-plan :days)) :date) |
| 53 | + {:day 4 :month 8 :week-day "Tuesday" :year 2020})) |
49 | 54 |
|
50 | | -(deftest insert-days-with-one-day-in-future |
| 55 | +(deftest "insert days with one day in the future" |
51 | 56 | (def plan (plan/build-plan :days @[(day/build-day (d/date 2020 8 6))])) |
52 | 57 | (def new-plan (insert-days plan(d/date 2020 8 5) (d/date 2020 8 4))) |
53 | 58 | (def day-2 ((new-plan :days) 1)) |
54 | | - (is (= 3 (length (new-plan :days)))) |
55 | | - (is (= (d/date 2020 8 5) (day-2 :date)))) |
| 59 | + (test (length (new-plan :days)) 3) |
| 60 | + (test (day-2 :date) |
| 61 | + {:day 5 :month 8 :week-day "Wednesday" :year 2020})) |
56 | 62 |
|
57 | 63 | ## ————————————————————————————————————————————————————————————————————————————————————————————————— |
58 | 64 | ## Test build-command |
59 | 65 |
|
60 | | -(deftest build-command-without-matching-arguments |
| 66 | +(deftest "without matching arguments" |
61 | 67 | (def arguments {"stats" true}) |
62 | | - (is (empty? (build-command arguments)))) |
| 68 | + (test (empty? (build-command arguments)) true)) |
63 | 69 |
|
64 | | -(deftest build-command-with-correct-arguments |
| 70 | +(deftest "with correct arguments" |
65 | 71 | (def arguments {"insert-days" "3"}) |
66 | 72 | (def result (build-command arguments)) |
67 | | - (is (tuple? (result :command)))) |
| 73 | + (test (tuple? (result :command)) true)) |
68 | 74 |
|
69 | | -(deftest build-command-with-incorrect-arguments |
| 75 | +(deftest "with incorrect arguments" |
70 | 76 | (def arguments {"insert-days" "three"}) |
71 | 77 | (def result (build-command arguments)) |
72 | | - (is (nil? (result :command))) |
73 | | - (is (= "--insert-days argument is not a number." (first (result :errors))))) |
74 | | - |
75 | | -(run-tests!) |
| 78 | + (test (nil? (result :command)) true) |
| 79 | + (test (first (result :errors)) "--insert-days argument is not a number.")) |
0 commit comments