|
28 | 28 | - [x] #work - Review open pull requests |
29 | 29 | - [x] #work - Fix the flaky test |
30 | 30 | ```) |
31 | | - (def plan ((parse plan-string) :plan)) |
| 31 | + (def parse-result (parse plan-string)) |
| 32 | + (def plan (parse-result :plan)) |
32 | 33 | (def inbox (plan :inbox)) |
33 | 34 | (def day-1 ((plan :days) 0)) |
34 | 35 | (def day-2 ((plan :days) 1)) |
|
51 | 52 | (test (not (task :done)) true) |
52 | 53 | (test (d/equal? (d/date 2020 7 30) (task :missed-on)) true)) |
53 | 54 | (test (= (d/date 2020 7 31) (day-2 :date)) true) |
54 | | - (test (= {:text "Talked to Mike & Molly"} ((day-2 :events) 0)) true) |
| 55 | + (let [event ((day-2 :events) 0)] |
| 56 | + (test (event :title) "Talked to Mike & Molly") |
| 57 | + (test (empty? (event :body)) true)) |
55 | 58 | (let [task ((day-2 :tasks) 0)] |
56 | 59 | (test (task :title) "#work - Review open pull requests") |
57 | 60 | (test (task :done) true)) |
|
182 | 185 | (test (= (d/date 2020 8 1) (day-1 :date)) true) |
183 | 186 | (test (= (d/date 2020 7 31) (day-2 :date)) true)) |
184 | 187 |
|
| 188 | +(deftest "parses a plan with an event that has a body" |
| 189 | + (def plan-string |
| 190 | + ``` |
| 191 | + # Main TODO |
| 192 | +
|
| 193 | + ## 2020-07-30, Thursday |
| 194 | +
|
| 195 | + - Talked to Mike & Molly |
| 196 | + - They moved to a new apartment |
| 197 | + - [x] Fix the lamp |
| 198 | + ```) |
| 199 | + (def parse-result (parse plan-string)) |
| 200 | + (def plan (parse-result :plan)) |
| 201 | + (test (length (plan :days)) 1) |
| 202 | + (let [day ((plan :days) 0) |
| 203 | + event ((day :events) 0) |
| 204 | + task ((day :tasks) 0)] |
| 205 | + (test (= (d/date 2020 7 30) (day :date)) true) |
| 206 | + (test (event :title) "Talked to Mike & Molly") |
| 207 | + (test ((event :body) 0) "- They moved to a new apartment") |
| 208 | + (test (task :title) "Fix the lamp") |
| 209 | + (test (task :done) true))) |
| 210 | + |
| 211 | +(deftest "parses a plan with an event without any tasks" |
| 212 | + (def plan-string |
| 213 | + ``` |
| 214 | + # Main TODO |
| 215 | +
|
| 216 | + ## 2020-07-30, Thursday |
| 217 | +
|
| 218 | + - Talked to Mike & Molly |
| 219 | + ```) |
| 220 | + (def plan ((parse plan-string) :plan)) |
| 221 | + (test (length (plan :days)) 1) |
| 222 | + (let [day ((plan :days) 0) |
| 223 | + event ((day :events) 0)] |
| 224 | + (test (event :title) "Talked to Mike & Molly"))) |
| 225 | + |
185 | 226 | (deftest "returns an error when the plan can't be parsed" |
186 | 227 | (def plan-string |
187 | 228 | ``` |
|
0 commit comments