mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-01-29 06:27:49 +00:00
committed by
John-David Dalton
parent
602cc3f03d
commit
659e8c019c
19
test/test.js
19
test/test.js
@@ -16020,6 +16020,14 @@
|
||||
{ 'a': 'y', 'b': 2 }
|
||||
];
|
||||
|
||||
var nestedObj = [
|
||||
{ id: '4', address: { zipCode: 4, streetName: 'Beta' } },
|
||||
{ id: '3', address: { zipCode: 3, streetName: 'Alpha' } },
|
||||
{ id: '1', address: { zipCode: 1, streetName: 'Alpha' } },
|
||||
{ id: '2', address: { zipCode: 2, streetName: 'Alpha' } },
|
||||
{ id: '5', address: { zipCode: 4, streetName: 'Alpha' } },
|
||||
];
|
||||
|
||||
QUnit.test('should sort by a single property by a specified order', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
@@ -16027,6 +16035,17 @@
|
||||
assert.deepEqual(actual, [objects[1], objects[3], objects[0], objects[2]]);
|
||||
});
|
||||
|
||||
QUnit.test('should sort by nested key in array format', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
var actual = _.orderBy(
|
||||
nestedObj,
|
||||
[['address', 'zipCode'], ['address.streetName']],
|
||||
['asc', 'desc'],
|
||||
);
|
||||
assert.deepEqual(actual, [nestedObj[2], nestedObj[3], nestedObj[1], nestedObj[0], nestedObj[4]]);
|
||||
});
|
||||
|
||||
QUnit.test('should sort by multiple properties by specified orders', function(assert) {
|
||||
assert.expect(1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user