From 083c5b703a925d42baf99313ded52894e8c6b63d Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Tue, 5 Apr 2016 08:23:34 -0700 Subject: [PATCH] Add `_.matchesProperty` test for matching `undefined` values of nested objects. --- test/test.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/test.js b/test/test.js index 641eb5907..d497f3ec2 100644 --- a/test/test.js +++ b/test/test.js @@ -7329,7 +7329,7 @@ }); }); - QUnit.test('`_.' + methodName + '` should return `false` for nested nullish values', function(assert) { + QUnit.test('`_.' + methodName + '` should return `false` for nullish values of nested objects', function(assert) { assert.expect(2); var values = [, null, undefined], @@ -13759,7 +13759,7 @@ }); }); - QUnit.test('should return `false` with deep paths when `object` is nullish', function(assert) { + QUnit.test('should return `false` for deep paths when `object` is nullish', function(assert) { assert.expect(2); var values = [, null, undefined], @@ -13968,6 +13968,22 @@ assert.deepEqual(actual, expected); }); + QUnit.test('should match `undefined` values of nested objects', function(assert) { + assert.expect(4); + + var object = { 'a': { 'b': undefined } }; + + lodashStable.each(['a.b', ['a', 'b']], function(path) { + var matches = _.matchesProperty(path, undefined); + assert.strictEqual(matches(object), true); + }); + + lodashStable.each(['a.a', ['a', 'a']], function(path) { + var matches = _.matchesProperty(path, undefined); + assert.strictEqual(matches(object), false); + }); + }); + QUnit.test('should match `undefined` values on primitives', function(assert) { assert.expect(2);