Compare commits

..

No commits in common. "e6a1bd13f0832123900b2fb70933ed3777892dd2" and "df7177962011e1b7bf1530174e16b8655dda99d0" have entirely different histories.

2 changed files with 28 additions and 38 deletions

View File

@ -434,16 +434,12 @@ field =
, description = description
, encoder =
\o ->
let
v =
encoder o
in
-- If the value matches the default, do not record
if E.encode 0 v == E.encode 0 (encoder (Tuple.first default)) then
if o == Tuple.first default then
Nothing
else
Maybe.Just v
Maybe.Just (encoder o)
, decoder = D.opFieldWithDefault fieldName default decoder
, docs = docs
, requiredness =

View File

@ -71,35 +71,29 @@ add4AFewTimes fuzz1 fuzz2 fuzz3 fuzz4 f roomFuzzer =
roomFuzzer
-- suite : Test
-- suite =
-- describe "Room"
-- [ fuzz3 fuzzer
-- Fuzz.string
-- Fuzz.string
-- "JSON Account Data can be overridden"
-- (\room key text ->
-- room
-- |> Room.setAccountData key (E.string text)
-- |> Room.getAccountData key
-- |> Maybe.map (D.decodeValue D.string)
-- |> Maybe.andThen Result.toMaybe
-- |> Expect.equal (Just text)
-- )
-- , fuzz fuzzer
-- "Room -> JSON -> Room is equal"
-- (\room ->
-- let
-- value : E.Value
-- value =
-- Room.encode room
-- in
-- value
-- |> D.decodeValue Room.decode
-- |> Result.toMaybe
-- |> Maybe.map Tuple.first
-- |> Maybe.map Room.encode
-- |> Maybe.map (E.encode 0)
-- |> Expect.equal (Just <| E.encode 0 value)
-- )
-- ]
suite : Test
suite =
describe "Room"
[ fuzz3 fuzzer
Fuzz.string
Fuzz.string
"JSON Account Data can be overridden"
(\room key text ->
room
|> Room.setAccountData key (E.string text)
|> Room.getAccountData key
|> Maybe.map (D.decodeValue D.string)
|> Maybe.andThen Result.toMaybe
|> Expect.equal (Just text)
)
, fuzz fuzzer
"Room -> JSON -> Room is equal"
(\room ->
room
|> Room.encode
|> D.decodeValue Room.decode
|> Result.toMaybe
|> Maybe.map Tuple.first
|> Expect.equal (Just room)
)
]