aboutsummaryrefslogtreecommitdiff
path: root/test/options.test.ts
diff options
context:
space:
mode:
authorjw2552018-02-06 22:27:57 +0000
committerjw2552018-02-06 22:27:57 +0000
commita46aa1e8948dbb46bc303ffb68ba6b2d39bd9df6 (patch)
tree1edb1056e44d3726b1195879a54a81501e0d8f22 /test/options.test.ts
parentMerge branch 'trh/payload-checker' of https://gitlab.cs.st-andrews.ac.uk/cs30... (diff)
downloadmedicine-a46aa1e8948dbb46bc303ffb68ba6b2d39bd9df6.tar.gz
medicine-a46aa1e8948dbb46bc303ffb68ba6b2d39bd9df6.zip

testing merged with typechecking

Diffstat (limited to 'test/options.test.ts')
-rw-r--r--test/options.test.ts52
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;
+ });
+ });
+});