-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTests.elm
30 lines (27 loc) · 1000 Bytes
/
Tests.elm
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
module Tests (..) where
import ElmTest exposing (..)
import Amount exposing (..)
import Model exposing (..)
all : Test
all =
suite
"A Test Suite"
[ init
|> accountBalance (AccountId "checking")
|> assertEqual (Just <| Amount 0 USD_Cents)
|> test "empty account"
, init
|> accountBalance (AccountId "zxcbvnm")
|> assertEqual (Nothing)
|> test "non-existent account"
, init
|> update (Transaction (Amount 100 USD_Cents) (AccountId "checking") (AccountId "expenses"))
|> Result.map (accountBalance (AccountId "checking"))
|> assertEqual (Ok <| Just <| Amount -100 USD_Cents)
|> test "transaction deducts from source"
, init
|> update (Transaction (Amount 100 USD_Cents) (AccountId "checking") (AccountId "expenses"))
|> Result.map (accountBalance (AccountId "expenses"))
|> assertEqual (Ok <| Just <| Amount 100 USD_Cents)
|> test "transaction adds to target"
]