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 | |
| 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')
| -rw-r--r-- | test/unit/options.unit.test.ts | 27 | ||||
| -rw-r--r-- | test/unit/types.unit.test.ts | 1 |
2 files changed, 28 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; + }); }); }); 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; |
