Ensure _.matches and _.matchesProperty work with function value params.

This commit is contained in:
jdalton
2015-03-23 09:24:05 -07:00
parent e7b4ada65f
commit 600a4e86e1
2 changed files with 21 additions and 1 deletions

View File

@@ -9494,6 +9494,16 @@
strictEqual(matches(object), true);
});
test('should match properties when `value` is a function', 1, function() {
function Foo() {}
Foo.a = function() {};
Foo.a.b = 1;
Foo.a.c = 2;
var matches = _.matches({ 'a': { 'b': 1 } });
strictEqual(matches(Foo), true);
});
test('should match properties when `value` is not a plain object', 1, function() {
function Foo(object) { _.assign(this, object); }
@@ -9672,6 +9682,16 @@
strictEqual(matches(object), true);
});
test('should match properties when `value` is a function', 1, function() {
function Foo() {}
Foo.a = function() {};
Foo.a.b = 1;
Foo.a.c = 2;
var matches = _.matchesProperty('a', { 'b': 1 });
strictEqual(matches(Foo), true);
});
test('should match properties when `value` is not a plain object', 1, function() {
function Foo(object) { _.assign(this, object); }