diff options
| author | Tom Harley | 2018-02-08 18:33:40 +0000 |
|---|---|---|
| committer | Tom Harley | 2018-02-08 18:33:40 +0000 |
| commit | 05f1604a853bb3e2a066ceab1305abbc11d1d99d (patch) | |
| tree | 0097be217b4e56dd2d1fae7159ee1f5a59f9576c /test/options.test.ts | |
| parent | Merge branch 'trh/db-orm' into trh/payload-checker (diff) | |
| download | medicine-05f1604a853bb3e2a066ceab1305abbc11d1d99d.tar.gz medicine-05f1604a853bb3e2a066ceab1305abbc11d1d99d.zip | |
Revert “Revert”Merge branch ‘testing’""
This reverts commit 0a9ebb01c27ed0a648922d243e877194977ce4d1.
Diffstat (limited to 'test/options.test.ts')
| -rw-r--r-- | test/options.test.ts | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/options.test.ts b/test/options.test.ts new file mode 100644 index 0000000..8622c73 --- /dev/null +++ b/test/options.test.ts @@ -0,0 +1,52 @@ +import * as mocha from 'mocha'; +import chai = require('chai'); +var should = chai.should(); + +import * as options from '../src/matcher/options'; +import { default as types } from '../src/matcher/types'; + +describe('Object Matching:', () => { + describe('Rough Matching', () => { + it('accepts basic things', () => { + let template = { + a: types.string + }; + let matchee = { + a: "yes" + }; + options.rough(template, matchee).should.be.true; + }); + it('accepts objects with superfluous properties', () => { + let template = { + a: types.number + }; + let matchee = { + a: 40, + b: 20 + }; + options.rough(template, matchee).should.be.true; + }); + it('rejects objects missing some properties', () => { + let template = { + a: types.boolean, + b: types.number, + c: types.number + }; + let matchee = { + b: 5 + }; + options.rough(template, matchee).should.be.false; + }); + it('accepts objects that omit not_present properties', () => { + let template = { + a: types.function, + b: types.not_present, + c: types.not_present + }; + let matchee = { + a: new Function() + }; + options.rough(template, matchee).should.be.true; + }); + }); +}); |
