From f60e3d9858f6037db3b27d5574ac95310127d302 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Wed, 7 Feb 2018 12:48:48 +0000 Subject: matching now supports nested functions --- src/matcher/options.test.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/matcher/options.test.ts') diff --git a/src/matcher/options.test.ts b/src/matcher/options.test.ts index f3d498c..058ef9e 100644 --- a/src/matcher/options.test.ts +++ b/src/matcher/options.test.ts @@ -63,5 +63,25 @@ describe('Object Matching:', () => { }; options.match(template, matchee).should.be.true; }); + it('accepts nested objects that match', () => { + let template = { + a: types.number, + b: { + ba: types.string, + bb: types.function + }, + c: types.boolean + }; + let matchee = { + a: 432, + b: { + ba: "barracus", + bb: new Function(), + }, + c: true, + x: false + }; + options.match(template, matchee).should.be.true; + }); }); }); -- cgit v1.2.1 From 5e482ce4408f2e1926d1e9af3270a52ffcc83df6 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Wed, 7 Feb 2018 14:18:55 +0000 Subject: added literal matching --- src/matcher/options.test.ts | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'src/matcher/options.test.ts') diff --git a/src/matcher/options.test.ts b/src/matcher/options.test.ts index 058ef9e..39c4b3e 100644 --- a/src/matcher/options.test.ts +++ b/src/matcher/options.test.ts @@ -75,7 +75,7 @@ describe('Object Matching:', () => { let matchee = { a: 432, b: { - ba: "barracus", + ba: "baracus", bb: new Function(), }, c: true, @@ -83,5 +83,23 @@ describe('Object Matching:', () => { }; options.match(template, matchee).should.be.true; }); + it('accepts literal matches', () => { + let template = { + a: "literal" + }; + let matchee = { + a: "literal" + }; + options.match(template, matchee).should.be.true; + }); + it('rejects incorrect literal matches', () => { + let template = { + g: 99 + }; + let matchee = { + g: 80 + }; + options.match(template, matchee).should.be.false; + }); }); }); -- cgit v1.2.1