File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# ## ————————————————————————————————————————————————————————————————————————————————————————————————
22# ## This module implements task entity and related functions.
3- # ##
4- # ## A task can have the following states: :checked, :open.
53
64(import ./date )
75
6+ (def states [:open :checked ])
7+
88(defn build-task [title state &opt body ]
99 (default body @[])
10- {:title title :body body :state state })
10+ (if (index-of state states )
11+ {:title title :body body :state state }
12+ (error (string " task doesn't support the state '" state " '" ))))
1113
1214(defn build-scheduled-task [line title schedule ]
1315 (def task (build-task title :open ))
Original file line number Diff line number Diff line change 1313 (test (task :body ) " Meeting agenda" )
1414 (test (task :state ) :open ))
1515
16+ (deftest " raises an error when the state is not valid"
17+ (test-error
18+ (task/build-task " Weekly meeting" :closed )
19+ " task doesn't support the state 'closed'" ))
20+
1621# # —————————————————————————————————————————————————————————————————————————————————————————————————
1722# # Test build-scheduled-task
1823(deftest " builds a new scheduled task"
You can’t perform that action at this time.
0 commit comments