aboutsummaryrefslogtreecommitdiff
path: root/src/matcher/options.test.ts
diff options
context:
space:
mode:
authorTom Harley2018-02-06 14:58:10 +0000
committerTom Harley2018-02-06 14:58:10 +0000
commit13a2c19212bf208e8a06ef1673ebd4595bcb849b (patch)
treece7856e21a6afcaa64b886786cf538b95602c4c7 /src/matcher/options.test.ts
parentEdited testing script (diff)
downloadmedicine-13a2c19212bf208e8a06ef1673ebd4595bcb849b.tar.gz
medicine-13a2c19212bf208e8a06ef1673ebd4595bcb849b.zip

started work on type checking

Diffstat (limited to 'src/matcher/options.test.ts')
-rw-r--r--src/matcher/options.test.ts52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/matcher/options.test.ts b/src/matcher/options.test.ts
new file mode 100644
index 0000000..6c2cfe5
--- /dev/null
+++ b/src/matcher/options.test.ts
@@ -0,0 +1,52 @@
+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.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;
+ });
+ });
+});