diff --git a/spec/TinyType.spec.ts b/spec/TinyType.spec.ts index 6a496a27..3777c459 100644 --- a/spec/TinyType.spec.ts +++ b/spec/TinyType.spec.ts @@ -204,6 +204,9 @@ describe('TinyType', () => { class People extends TinyTypeOf() { } + class FirstNames extends TinyTypeOf>() { + } + describe('::toJSON', () => { given( @@ -241,6 +244,20 @@ describe('TinyType', () => { }]); }); + it(`should serialise undefined array values as null`, () => { + const firstNames = new FirstNames([ + new FirstName('Alice'), + undefined, + new FirstName('Cecil'), + ]); + + expect(firstNames.toJSON()).to.deep.equal([ + 'Alice', + null, + 'Cecil', + ]); + }); + it(`should serialise a plain-old JavaScript object`, () => { class Parameters extends TinyTypeOf<{ [parameter: string]: string }>() { }