Skip to content

Commit

Permalink
test(tiny-types): updated specs
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-molak committed Mar 16, 2024
1 parent d378c1c commit 4dd4bd2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/TinyType.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,9 @@ describe('TinyType', () => {
class People extends TinyTypeOf<Person[]>() {
}

class FirstNames extends TinyTypeOf<Array<FirstName | undefined>>() {
}

describe('::toJSON', () => {

given<TinyType & { value: any }>(
Expand Down Expand Up @@ -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 }>() {
}
Expand Down

0 comments on commit 4dd4bd2

Please sign in to comment.