-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathStateSpec.hs
60 lines (57 loc) · 2.2 KB
/
StateSpec.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module StateSpec (spec) where
import Data.Time (UTCTime)
import Test.Hspec
import Unfog.Event.Type (Event (..))
import Unfog.State as State
import Unfog.Task (Task (..))
import qualified Unfog.Task as Task
spec :: Spec
spec = parallel $ do
let now = read "2020-01-01 00:00:00 UTC" :: UTCTime
let tomorrow = read "2020-01-02 00:00:00 UTC" :: UTCTime
it "rebuild" $ do
rebuild [] `shouldBe` State.new
rebuild
[ TaskAdded now "id" "desc" Nothing Nothing
]
`shouldBe` State.new {_tasks = [Task.new {_id = "id", _desc = "desc"}]}
rebuild
[ TaskAdded now "id" "desc" (Just "proj") Nothing
]
`shouldBe` State.new {_tasks = [Task.new {_id = "id", _desc = "desc", _project = Just "proj"}]}
rebuild
[ TaskAdded now "id" "desc" Nothing (Just now)
]
`shouldBe` State.new {_tasks = [Task.new {_id = "id", _desc = "desc", _due = Just now}]}
rebuild
[ TaskAdded now "id" "desc" Nothing Nothing,
TaskEdited now "id" "desc" (Just "proj") Nothing
]
`shouldBe` State.new {_tasks = [Task.new {_id = "id", _desc = "desc", _project = Just "proj"}]}
rebuild
[ TaskAdded now "id" "desc" Nothing Nothing,
TaskStarted now "id"
]
`shouldBe` State.new {_tasks = [Task.new {_id = "id", _desc = "desc", _active = Just now, _starts = [now]}]}
rebuild
[ TaskAdded now "id" "desc" Nothing Nothing,
TaskStarted now "id",
TaskStopped tomorrow "id"
]
`shouldBe` State.new {_tasks = [Task.new {_id = "id", _desc = "desc", _starts = [now], _stops = [tomorrow]}]}
rebuild
[ TaskAdded now "id" "desc" Nothing Nothing,
TaskStarted now "id",
TaskDid tomorrow "id"
]
`shouldBe` State.new {_tasks = [Task.new {_id = "id", _desc = "desc", _starts = [now], _stops = [tomorrow], _done = Just tomorrow}]}
rebuild
[ TaskAdded now "id" "desc" Nothing Nothing,
TaskStarted now "id",
TaskDeleted tomorrow "id"
]
`shouldBe` State.new {_tasks = [Task.new {_id = "id", _desc = "desc", _starts = [now], _stops = [tomorrow], _deleted = Just tomorrow}]}
rebuild
[ ContextEdited now (Just "proj")
]
`shouldBe` State.new {_ctx = Just "proj"}