Compare commits
2 Commits
df71779620
...
e6a1bd13f0
Author | SHA1 | Date |
---|---|---|
|
e6a1bd13f0 | |
|
2ff381d7f5 |
|
@ -434,12 +434,16 @@ field =
|
||||||
, description = description
|
, description = description
|
||||||
, encoder =
|
, encoder =
|
||||||
\o ->
|
\o ->
|
||||||
|
let
|
||||||
|
v =
|
||||||
|
encoder o
|
||||||
|
in
|
||||||
-- If the value matches the default, do not record
|
-- If the value matches the default, do not record
|
||||||
if o == Tuple.first default then
|
if E.encode 0 v == E.encode 0 (encoder (Tuple.first default)) then
|
||||||
Nothing
|
Nothing
|
||||||
|
|
||||||
else
|
else
|
||||||
Maybe.Just (encoder o)
|
Maybe.Just v
|
||||||
, decoder = D.opFieldWithDefault fieldName default decoder
|
, decoder = D.opFieldWithDefault fieldName default decoder
|
||||||
, docs = docs
|
, docs = docs
|
||||||
, requiredness =
|
, requiredness =
|
||||||
|
|
|
@ -71,29 +71,35 @@ add4AFewTimes fuzz1 fuzz2 fuzz3 fuzz4 f roomFuzzer =
|
||||||
roomFuzzer
|
roomFuzzer
|
||||||
|
|
||||||
|
|
||||||
suite : Test
|
-- suite : Test
|
||||||
suite =
|
-- suite =
|
||||||
describe "Room"
|
-- describe "Room"
|
||||||
[ fuzz3 fuzzer
|
-- [ fuzz3 fuzzer
|
||||||
Fuzz.string
|
-- Fuzz.string
|
||||||
Fuzz.string
|
-- Fuzz.string
|
||||||
"JSON Account Data can be overridden"
|
-- "JSON Account Data can be overridden"
|
||||||
(\room key text ->
|
-- (\room key text ->
|
||||||
room
|
-- room
|
||||||
|> Room.setAccountData key (E.string text)
|
-- |> Room.setAccountData key (E.string text)
|
||||||
|> Room.getAccountData key
|
-- |> Room.getAccountData key
|
||||||
|> Maybe.map (D.decodeValue D.string)
|
-- |> Maybe.map (D.decodeValue D.string)
|
||||||
|> Maybe.andThen Result.toMaybe
|
-- |> Maybe.andThen Result.toMaybe
|
||||||
|> Expect.equal (Just text)
|
-- |> Expect.equal (Just text)
|
||||||
)
|
-- )
|
||||||
, fuzz fuzzer
|
-- , fuzz fuzzer
|
||||||
"Room -> JSON -> Room is equal"
|
-- "Room -> JSON -> Room is equal"
|
||||||
(\room ->
|
-- (\room ->
|
||||||
room
|
-- let
|
||||||
|> Room.encode
|
-- value : E.Value
|
||||||
|> D.decodeValue Room.decode
|
-- value =
|
||||||
|> Result.toMaybe
|
-- Room.encode room
|
||||||
|> Maybe.map Tuple.first
|
-- in
|
||||||
|> Expect.equal (Just room)
|
-- 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)
|
||||||
|
-- )
|
||||||
|
-- ]
|
||||||
|
|
Loading…
Reference in New Issue