diff options
| author | Hafeez | 2018-04-14 17:35:39 +0100 |
|---|---|---|
| committer | Hafeez | 2018-04-14 17:35:39 +0100 |
| commit | c619c845822e0019d988bdcdb760ffd7a220d601 (patch) | |
| tree | 449bb5b827300cf52e7e533f580c6ab36bf8e4c4 /test/unit/options.unit.test.ts | |
| parent | Merge branch 'trh/gets' of gitlab.cs.st-andrews.ac.uk:cs3099group-be-4/projec... (diff) | |
| parent | fixed 1 test in auth.routes.test.ts (diff) | |
| download | medicine-c619c845822e0019d988bdcdb760ffd7a220d601.tar.gz medicine-c619c845822e0019d988bdcdb760ffd7a220d601.zip | |
merge
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; + }); }); }); |
