mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Add _.matchesProperty test for matching undefined values of nested objects.
This commit is contained in:
20
test/test.js
20
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);
|
assert.expect(2);
|
||||||
|
|
||||||
var values = [, null, undefined],
|
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);
|
assert.expect(2);
|
||||||
|
|
||||||
var values = [, null, undefined],
|
var values = [, null, undefined],
|
||||||
@@ -13968,6 +13968,22 @@
|
|||||||
assert.deepEqual(actual, expected);
|
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) {
|
QUnit.test('should match `undefined` values on primitives', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user