aboutsummaryrefslogtreecommitdiff
path: root/src/matcher/options.test.ts
diff options
context:
space:
mode:
authorjw2552018-02-06 22:34:53 +0000
committerjw2552018-02-06 22:34:53 +0000
commit1520a13a7144e6a0569f589d3aa5fdddc8136b8c (patch)
tree0494a51e42a1491621bdc33e3742e9b0f49619f7 /src/matcher/options.test.ts
parentMerge branch 'cjd24/stubsgres' into 'master' (diff)
parenttesting merged with typechecking (diff)
downloadmedicine-1520a13a7144e6a0569f589d3aa5fdddc8136b8c.tar.gz
medicine-1520a13a7144e6a0569f589d3aa5fdddc8136b8c.zip

Merge branch ‘testing’

Diffstat (limited to 'src/matcher/options.test.ts')
-rw-r--r--src/matcher/options.test.ts67
1 files changed, 67 insertions, 0 deletions
diff --git a/src/matcher/options.test.ts b/src/matcher/options.test.ts
new file mode 100644
index 0000000..f3d498c
--- /dev/null
+++ b/src/matcher/options.test.ts
@@ -0,0 +1,67 @@
+import * as mocha from 'mocha';
+import chai = require('chai');
+var should = chai.should();
+
+import * as options from './options';
+import { default as types } from './types';
+
+describe('Object Matching:', () => {
+ describe('Rough Matching', () => {
+ it('accepts basic things', () => {
+ let template = {
+ a: types.string
+ };
+ let matchee = {
+ a: "yes"
+ };
+ options.match(template, matchee).should.be.true;
+ });
+ it('accepts objects with superfluous properties', () => {
+ let template = {
+ a: types.number
+ };
+ let matchee = {
+ a: 40,
+ b: 20
+ };
+ options.match(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.match(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.match(template, matchee).should.be.true;
+ });
+ it('rejects empty objects for non-empty templates', () => {
+ let template = {
+ a: types.boolean
+ };
+ let matchee = {
+ };
+ options.match(template, matchee).should.be.false;
+ });
+ it('accepts empty objects for empty templates', () => {
+ let template = {
+ };
+ let matchee = {
+ };
+ options.match(template, matchee).should.be.true;
+ });
+ });
+});