diff options
Diffstat (limited to 'test/unit/options.unit.test.ts')
| -rw-r--r-- | test/unit/options.unit.test.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/test/unit/options.unit.test.ts b/test/unit/options.unit.test.ts index 1925835..a4c879a 100644 --- a/test/unit/options.unit.test.ts +++ b/test/unit/options.unit.test.ts @@ -159,5 +159,32 @@ 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; + }); + 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; + }); }); }); |
