From 68ccb52d1d3a08fcdf6f5e895125606b14fc53f1 Mon Sep 17 00:00:00 2001 From: Jason Kuhrt Date: Tue, 23 Aug 2022 23:08:18 -0400 Subject: [PATCH] tests: cover defaults applying to decode return closes #107 --- tests/record/codec/custom.spec.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/record/codec/custom.spec.ts b/tests/record/codec/custom.spec.ts index 7397748..238fcb3 100644 --- a/tests/record/codec/custom.spec.ts +++ b/tests/record/codec/custom.spec.ts @@ -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() })