Add more tests for _.sortByAll and _.sortByOrder used as iteratees of _.reduce.

This commit is contained in:
jdalton
2015-04-11 20:58:31 -07:00
parent f82cbbab1c
commit ff6bbaed19
2 changed files with 14 additions and 8 deletions

View File

@@ -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), []);
}); });

View File

@@ -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);
}); });
}); });