mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-07 10:07:48 +00:00
Add test for _.sortBy sorting undefined and NaN values.
This commit is contained in:
10
test/test.js
10
test/test.js
@@ -9832,16 +9832,16 @@
|
|||||||
deepEqual(actual, stableOrder);
|
deepEqual(actual, stableOrder);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should work with `undefined` values', 1, function() {
|
|
||||||
var array = [undefined, 4, 1, undefined, 3, 2];
|
|
||||||
deepEqual(_.sortBy(array, _.identity), [1, 2, 3, 4, undefined, undefined]);
|
|
||||||
});
|
|
||||||
|
|
||||||
test('should use `_.identity` when no predicate is provided', 1, function() {
|
test('should use `_.identity` when no predicate is provided', 1, function() {
|
||||||
var actual = _.sortBy([3, 2, 1]);
|
var actual = _.sortBy([3, 2, 1]);
|
||||||
deepEqual(actual, [1, 2, 3]);
|
deepEqual(actual, [1, 2, 3]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should move `undefined` and `NaN` values to the end', 1, function() {
|
||||||
|
var array = [NaN, undefined, 4, 1, undefined, 3, NaN, 2];
|
||||||
|
deepEqual(_.sortBy(array), [1, 2, 3, 4, undefined, undefined, NaN, NaN]);
|
||||||
|
});
|
||||||
|
|
||||||
test('should provide the correct `callback` arguments', 1, function() {
|
test('should provide the correct `callback` arguments', 1, function() {
|
||||||
var args;
|
var args;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user