From 04f1a799dc1ce622ea35195c226ea65ab3ef6fcb Mon Sep 17 00:00:00 2001 From: jdalton Date: Tue, 7 Apr 2015 00:23:16 -0700 Subject: [PATCH] Cleanup `_.matches` tests. --- test/test.js | 74 ++++++++++++++++++++++++++-------------------------- 1 file changed, 37 insertions(+), 37 deletions(-) diff --git a/test/test.js b/test/test.js index 38a4063ca..d42a7500d 100644 --- a/test/test.js +++ b/test/test.js @@ -9434,6 +9434,43 @@ strictEqual(matches(object), true); }); + test('should match inherited `value` properties', 1, function() { + function Foo() { this.a = 1; } + Foo.prototype.b = 2; + + var object = { 'a': new Foo }, + matches = _.matches({ 'a': { 'b': 2 } }); + + strictEqual(matches(object), true); + }); + + test('should not match by inherited `source` properties', 1, function() { + function Foo() { this.a = 1; } + Foo.prototype.b = 2; + + var objects = [{ 'a': 1 }, { 'a': 1, 'b': 2 }], + source = new Foo, + matches = _.matches(source), + actual = _.map(objects, matches), + expected = _.map(objects, _.constant(true)); + + deepEqual(actual, expected); + }); + + test('should work when `object` is nullish', 1, function() { + var values = [, null, undefined], + expected = _.map(values, _.constant(false)), + matches = _.matches({ 'a': 1 }); + + var actual = _.map(values, function(value, index) { + try { + return index ? matches(value) : matches(); + } catch(e) {} + }); + + deepEqual(actual, expected); + }); + test('should compare a variety of `source` values', 2, function() { var object1 = { 'a': false, 'b': true, 'c': '3', 'd': 4, 'e': [5], 'f': { 'g': 6 } }, object2 = { 'a': 0, 'b': 1, 'c': 3, 'd': '4', 'e': ['5'], 'f': { 'g': '6' } }, @@ -9475,20 +9512,6 @@ }); }); - test('should work when `object` is nullish', 1, function() { - var values = [, null, undefined], - expected = _.map(values, _.constant(false)), - matches = _.matches({ 'a': 1 }); - - var actual = _.map(values, function(value, index) { - try { - return index ? matches(value) : matches(); - } catch(e) {} - }); - - deepEqual(actual, expected); - }); - test('should return `true` when comparing an empty `source`', 1, function() { var object = { 'a': 1 }, expected = _.map(empties, _.constant(true)); @@ -9566,16 +9589,6 @@ deepEqual(actual, expected); }); - test('should match inherited `value` properties', 1, function() { - function Foo() { this.a = 1; } - Foo.prototype.b = 2; - - var object = { 'a': new Foo }, - matches = _.matches({ 'a': { 'b': 2 } }); - - strictEqual(matches(object), true); - }); - test('should match properties when `value` is a function', 1, function() { function Foo() {} Foo.a = { 'b': 1, 'c': 2 }; @@ -9593,19 +9606,6 @@ strictEqual(matches(object), true); }); - test('should not match by inherited `source` properties', 1, function() { - function Foo() { this.a = 1; } - Foo.prototype.b = 2; - - var objects = [{ 'a': 1 }, { 'a': 1, 'b': 2 }], - source = new Foo, - matches = _.matches(source), - actual = _.map(objects, matches), - expected = _.map(objects, _.constant(true)); - - deepEqual(actual, expected); - }); - test('should work with a function for `source`', 1, function() { function source() {}