Skip to content

Commit

Permalink
add a round-trip test for players
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianHicks committed Sep 11, 2020
1 parent 5456165 commit 33847b0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
4 changes: 3 additions & 1 deletion elm.json
Expand Up @@ -27,7 +27,9 @@
}
},
"test-dependencies": {
"direct": {},
"direct": {
"elm-explorations/test": "1.2.2"
},
"indirect": {}
}
}
24 changes: 24 additions & 0 deletions 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)

0 comments on commit 33847b0

Please sign in to comment.