diff --git a/elm.json b/elm.json index 7e98af0..807158b 100644 --- a/elm.json +++ b/elm.json @@ -27,7 +27,9 @@ } }, "test-dependencies": { - "direct": {}, + "direct": { + "elm-explorations/test": "1.2.2" + }, "indirect": {} } } diff --git a/tests/PlayerTest.elm b/tests/PlayerTest.elm new file mode 100644 index 0000000..9d2b4fa --- /dev/null +++ b/tests/PlayerTest.elm @@ -0,0 +1,24 @@ +module PlayerTest exposing (..) + +import Expect +import Fuzz exposing (Fuzzer) +import Json.Decode as Decode +import Player exposing (Player) +import Test exposing (..) + + +roundTripDecoderTest : Test +roundTripDecoderTest = + fuzz playerFuzzer "encode and decode are symmetrical" <| + \player -> + Player.encode player + |> Decode.decodeValue Player.decoder + |> Expect.equal (Ok player) + + +playerFuzzer : Fuzzer Player +playerFuzzer = + Fuzz.map3 Player + Fuzz.string + (Fuzz.intRange 1000 3000) + (Fuzz.intRange 0 50)