mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-02 16:17:50 +00:00
Make _.sortByOrder support orders of "asc" and "desc".
This commit is contained in:
16
test/test.js
16
test/test.js
@@ -14525,14 +14525,18 @@
|
||||
{ 'a': 'y', 'b': 2 }
|
||||
];
|
||||
|
||||
test('should sort multiple properties by specified orders', 1, function() {
|
||||
var actual = _.sortByOrder(objects, ['a', 'b'], [false, true]);
|
||||
deepEqual(actual, [objects[3], objects[1], objects[2], objects[0]]);
|
||||
test('should sort multiple properties by specified orders', 2, function() {
|
||||
_.each([[false, true], ['desc', 'asc']], function(orders) {
|
||||
var actual = _.sortByOrder(objects, ['a', 'b'], orders);
|
||||
deepEqual(actual, [objects[3], objects[1], objects[2], objects[0]]);
|
||||
});
|
||||
});
|
||||
|
||||
test('should sort a property in ascending order when its order is not specified', 1, function() {
|
||||
var actual = _.sortByOrder(objects, ['a', 'b'], [false]);
|
||||
deepEqual(actual, [objects[3], objects[1], objects[2], objects[0]]);
|
||||
test('should sort a property in ascending order when its order is not specified', 2, function() {
|
||||
_.each([[false], ['desc']], function(orders) {
|
||||
var actual = _.sortByOrder(objects, ['a', 'b'], orders);
|
||||
deepEqual(actual, [objects[3], objects[1], objects[2], objects[0]]);
|
||||
});
|
||||
});
|
||||
}());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user