mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 10:57:49 +00:00
Add omit and pick tests for -0 keys.
This commit is contained in:
38
test/test.js
38
test/test.js
@@ -16084,9 +16084,10 @@
|
|||||||
|
|
||||||
if (methodName == 'omitBy') {
|
if (methodName == 'omitBy') {
|
||||||
prop = function(object, props) {
|
prop = function(object, props) {
|
||||||
props = lodashStable.isArray(props) ? props : [props];
|
props = lodashStable.castArray(props);
|
||||||
return function(value) {
|
return function(value) {
|
||||||
return lodashStable.some(props, function(key) {
|
return lodashStable.some(props, function(key) {
|
||||||
|
key = lodashStable.isSymbol(key) ? key : lodashStable.toString(key);
|
||||||
return object[key] === value;
|
return object[key] === value;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -16108,6 +16109,22 @@
|
|||||||
assert.deepEqual(func(new Foo, prop(object, ['a', 'c'])), expected);
|
assert.deepEqual(func(new Foo, prop(object, ['a', 'c'])), expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('`_.' + methodName + '` should preserve the sign of `0`', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
var object = { '-0': 'a', '0': 'b' },
|
||||||
|
negExp = { '-0': 'a' },
|
||||||
|
posExp = { '0': 'b' },
|
||||||
|
expected = [posExp, posExp, negExp, negExp],
|
||||||
|
props = [-0, Object(-0), 0, Object(0)];
|
||||||
|
|
||||||
|
var actual = lodashStable.map(props, function(key) {
|
||||||
|
return func(object, prop(object, key));
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(actual, expected);
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('`_.' + methodName + '` should include symbol properties', function(assert) {
|
QUnit.test('`_.' + methodName + '` should include symbol properties', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
@@ -17297,9 +17314,10 @@
|
|||||||
|
|
||||||
if (methodName == 'pickBy') {
|
if (methodName == 'pickBy') {
|
||||||
prop = function(object, props) {
|
prop = function(object, props) {
|
||||||
props = lodashStable.isArray(props) ? props : [props];
|
props = lodashStable.castArray(props);
|
||||||
return function(value) {
|
return function(value) {
|
||||||
return lodashStable.some(props, function(key) {
|
return lodashStable.some(props, function(key) {
|
||||||
|
key = lodashStable.isSymbol(key) ? key : lodashStable.toString(key);
|
||||||
return object[key] === value;
|
return object[key] === value;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -17322,6 +17340,22 @@
|
|||||||
assert.deepEqual(func(foo, prop(foo, ['a', 'c'])), expected);
|
assert.deepEqual(func(foo, prop(foo, ['a', 'c'])), expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test('`_.' + methodName + '` should preserve the sign of `0`', function(assert) {
|
||||||
|
assert.expect(1);
|
||||||
|
|
||||||
|
var object = { '-0': 'a', '0': 'b' },
|
||||||
|
negExp = { '-0': 'a' },
|
||||||
|
posExp = { '0': 'b' },
|
||||||
|
expected = [negExp, negExp, posExp, posExp],
|
||||||
|
props = [-0, Object(-0), 0, Object(0)];
|
||||||
|
|
||||||
|
var actual = lodashStable.map(props, function(key) {
|
||||||
|
return func(object, prop(object, key));
|
||||||
|
});
|
||||||
|
|
||||||
|
assert.deepEqual(actual, expected);
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test('`_.' + methodName + '` should pick symbol properties', function(assert) {
|
QUnit.test('`_.' + methodName + '` should pick symbol properties', function(assert) {
|
||||||
assert.expect(2);
|
assert.expect(2);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user