mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-10 02:47:50 +00:00
Add more tests for _.sortByAll and _.sortByOrder used as iteratees of _.reduce.
This commit is contained in:
@@ -7331,7 +7331,7 @@
|
|||||||
}
|
}
|
||||||
var guard = args[2];
|
var guard = args[2];
|
||||||
if (guard && isIterateeCall(args[0], args[1], guard)) {
|
if (guard && isIterateeCall(args[0], args[1], guard)) {
|
||||||
args = args[0];
|
args.length = 1;
|
||||||
}
|
}
|
||||||
return baseSortByOrder(collection, baseFlatten(args), []);
|
return baseSortByOrder(collection, baseFlatten(args), []);
|
||||||
});
|
});
|
||||||
|
|||||||
20
test/test.js
20
test/test.js
@@ -14197,7 +14197,7 @@
|
|||||||
deepEqual(actual, [objects[2], objects[0], objects[3], objects[1], null, undefined]);
|
deepEqual(actual, [objects[2], objects[0], objects[3], objects[1], null, undefined]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('`_.' + methodName + '` should work as an iteratee for methods like `_.reduce`', 1, function() {
|
test('`_.' + methodName + '` should work as an iteratee for methods like `_.reduce`', 3, function() {
|
||||||
var objects = [
|
var objects = [
|
||||||
{ 'a': 'x', '0': 3 },
|
{ 'a': 'x', '0': 3 },
|
||||||
{ 'a': 'y', '0': 4 },
|
{ 'a': 'y', '0': 4 },
|
||||||
@@ -14205,14 +14205,20 @@
|
|||||||
{ 'a': 'y', '0': 2 }
|
{ 'a': 'y', '0': 2 }
|
||||||
];
|
];
|
||||||
|
|
||||||
var funcs = [func, _.partialRight(func, 'bogus')],
|
var funcs = [func, _.partialRight(func, 'bogus')];
|
||||||
expected = _.map(funcs, _.constant([objects[0], objects[2], objects[1], objects[3]]));
|
|
||||||
|
|
||||||
var actual = _.map(funcs, function(func) {
|
_.each(['a', 0, [0]], function(props, index) {
|
||||||
return _.reduce([['a']], func, objects);
|
var expected = _.map(funcs, _.constant(index
|
||||||
|
? [objects[2], objects[3], objects[0], objects[1]]
|
||||||
|
: [objects[0], objects[2], objects[1], objects[3]]
|
||||||
|
));
|
||||||
|
|
||||||
|
var actual = _.map(funcs, function(func) {
|
||||||
|
return _.reduce([props], func, objects);
|
||||||
|
});
|
||||||
|
|
||||||
|
deepEqual(actual, expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
deepEqual(actual, expected);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user