From 9c0ff9a0b7d73e5e2a12c4f87d1aa586c59adec9 Mon Sep 17 00:00:00 2001 From: jw255 Date: Fri, 13 Apr 2018 21:12:53 +0100 Subject: only 12 failing tests :D --- test/unit/options.unit.test.ts | 10 ++++++++++ test/unit/types.unit.test.ts | 1 + 2 files changed, 11 insertions(+) (limited to 'test/unit') diff --git a/test/unit/options.unit.test.ts b/test/unit/options.unit.test.ts index 1925835..29000de 100644 --- a/test/unit/options.unit.test.ts +++ b/test/unit/options.unit.test.ts @@ -159,5 +159,15 @@ describe('Matching:', () => { }; options.match(template, matchee).should.be.false; }); + it('accepts optional matches', () => { + const template = { + a: options.optional(types.array), + b: options.optional(types.anything) + }; + const matchee = { + b: [] + }; + options.match(template)(matchee).should.be.true; + }); }); }); diff --git a/test/unit/types.unit.test.ts b/test/unit/types.unit.test.ts index ad0f99c..f18d5a1 100644 --- a/test/unit/types.unit.test.ts +++ b/test/unit/types.unit.test.ts @@ -30,6 +30,7 @@ describe('Type Checking:', () => { types.anything(1).should.be.true; types.anything('string').should.be.true; types.anything(false).should.be.true; + types.anything([]).should.be.true; }); it('accepts null', () => { types.anything(null).should.be.true; -- cgit v1.2.1 From 8d355d34cd309122e67f694e22f2023db205794f Mon Sep 17 00:00:00 2001 From: jw255 Date: Fri, 13 Apr 2018 22:07:19 +0100 Subject: much better --- test/unit/options.unit.test.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'test/unit') diff --git a/test/unit/options.unit.test.ts b/test/unit/options.unit.test.ts index 29000de..a4c879a 100644 --- a/test/unit/options.unit.test.ts +++ b/test/unit/options.unit.test.ts @@ -169,5 +169,22 @@ describe('Matching:', () => { }; options.match(template)(matchee).should.be.true; }); + it('big bad unit test', () => { + const matchee = { status: 'success', + data: [ { privilege: 'admin', description: 'null', internal: false }, + { privilege: 'logging', + description: 'Allows Post to Log', + internal: false } ] }; + const template = { + status: types.string, + data: options.optional(types.anything), + error: options.optional(types.string), + error_description: options.optional(types.string), + user_message: options.optional(types.string), + error_data: options.optional(types.anything) + }; + + options.match(template)(matchee).should.be.true; + }); }); }); -- cgit v1.2.1