drathier/elm-test-tables/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

Fuzz.Json

Fuzz.Json lets you test your json encoders and decoders.

roundtripTests =
  describe "json roundtrip tests"
    [ roundtrip "int encode/decode" Fuzz.int Json.Encode.int Json.Decode.int
    , roundtrip "float encode/decode" Fuzz.float Json.Encode.float Json.Decode.float
    , roundtrip "string encode/decode" Fuzz.string Json.Encode.string Json.Decode.string
    , roundtrip "bool encode/decode" Fuzz.bool Json.Encode.bool Json.Decode.bool
    ]
roundtrip : String -> Fuzzer a -> (a -> Value) -> Decoder a -> Test

Roundtrip takes a fuzzer, a json encoder, a json decoder, and sees if an encode/decode cycle succeeds without losing any data.