mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 08:07:50 +00:00
Ensure sortedIndex methods align with sortBy for symbols.
This commit is contained in:
17
test/test.js
17
test/test.js
@@ -20437,19 +20437,22 @@
|
||||
});
|
||||
|
||||
QUnit.test('`_.' + methodName + '` should align with `_.sortBy`', function(assert) {
|
||||
assert.expect(10);
|
||||
assert.expect(12);
|
||||
|
||||
var expected = [1, '2', {}, null, undefined, NaN, NaN];
|
||||
var symbol1 = Symbol ? Symbol('a') : null,
|
||||
symbol2 = Symbol ? Symbol('b') : null,
|
||||
expected = [1, '2', {}, symbol1, symbol2, null, undefined, NaN, NaN];
|
||||
|
||||
lodashStable.each([
|
||||
[NaN, null, 1, '2', {}, NaN, undefined],
|
||||
['2', null, 1, NaN, {}, NaN, undefined]
|
||||
[NaN, symbol1, null, 1, '2', {}, symbol2, NaN, undefined],
|
||||
['2', null, 1, symbol1, NaN, {}, NaN, symbol2, undefined]
|
||||
], function(array) {
|
||||
assert.deepEqual(_.sortBy(array), expected);
|
||||
assert.strictEqual(func(expected, 3), 2);
|
||||
assert.strictEqual(func(expected, null), isSortedIndex ? 3 : 4);
|
||||
assert.strictEqual(func(expected, undefined), isSortedIndex ? 4 : 5);
|
||||
assert.strictEqual(func(expected, NaN), isSortedIndex ? 5 : 7);
|
||||
assert.strictEqual(func(expected, symbol1), (isSortedIndex ? 3 : (Symbol ? 5 : 6)));
|
||||
assert.strictEqual(func(expected, null), (isSortedIndex ? (Symbol ? 5 : 3) : 6));
|
||||
assert.strictEqual(func(expected, undefined), isSortedIndex ? 6 : 7);
|
||||
assert.strictEqual(func(expected, NaN), isSortedIndex ? 7 : 9);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user