Skip to content

Commit

Permalink
tests: cover defaults applying to decode return
Browse files Browse the repository at this point in the history
closes #107
  • Loading branch information
jasonkuhrt committed Aug 24, 2022
1 parent 550efef commit 68ccb52
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/record/codec/custom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,16 @@ describe(`decoder`, () => {
from: () => ({}),
})
})
it(`defaults are applied`, () => {
const A = Alge.record($A)
.schema({ a: z.number().default(1) })
.codec(`foo`, {
to: () => ``,
from: () => ({}),
})
.done()
expect(A.from.foo(``)).toMatchObject({ a: 1 })
})
it(`null if decoding not possible`, () => {
const A = Alge.record($A)
.schema({ a: z.number() })
Expand Down

0 comments on commit 68ccb52

Please sign in to comment.