Ensure sortedIndex methods align with sortBy for symbols.

This commit is contained in:
John-David Dalton
2016-04-21 00:44:23 -07:00
parent 3c144b8601
commit 32b813e42b

View File

@@ -20437,19 +20437,22 @@
}); });
QUnit.test('`_.' + methodName + '` should align with `_.sortBy`', function(assert) { 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([ lodashStable.each([
[NaN, null, 1, '2', {}, NaN, undefined], [NaN, symbol1, null, 1, '2', {}, symbol2, NaN, undefined],
['2', null, 1, NaN, {}, NaN, undefined] ['2', null, 1, symbol1, NaN, {}, NaN, symbol2, undefined]
], function(array) { ], function(array) {
assert.deepEqual(_.sortBy(array), expected); assert.deepEqual(_.sortBy(array), expected);
assert.strictEqual(func(expected, 3), 2); assert.strictEqual(func(expected, 3), 2);
assert.strictEqual(func(expected, null), isSortedIndex ? 3 : 4); assert.strictEqual(func(expected, symbol1), (isSortedIndex ? 3 : (Symbol ? 5 : 6)));
assert.strictEqual(func(expected, undefined), isSortedIndex ? 4 : 5); assert.strictEqual(func(expected, null), (isSortedIndex ? (Symbol ? 5 : 3) : 6));
assert.strictEqual(func(expected, NaN), isSortedIndex ? 5 : 7); assert.strictEqual(func(expected, undefined), isSortedIndex ? 6 : 7);
assert.strictEqual(func(expected, NaN), isSortedIndex ? 7 : 9);
}); });
}); });
}); });