Ensure _.min and _.max can be used as the callback of _.map. [closes #379]

This commit is contained in:
John-David Dalton
2013-10-29 09:32:40 -07:00
parent 3fa2e7e12e
commit ac8f8d0dd6
8 changed files with 156 additions and 100 deletions

View File

@@ -917,7 +917,7 @@
deepEqual(args, [klass]);
});
test('`_.' + methodName + '`should support the `thisArg` argument', 1, function() {
test('`_.' + methodName + '` should support the `thisArg` argument', 1, function() {
var actual = func('a', function(value) {
return this[value];
}, { 'a': 'A' });
@@ -4668,7 +4668,7 @@
deepEqual(args, expected);
});
test('`_.' + methodName + '`should support the `thisArg` argument', 1, function() {
test('`_.' + methodName + '` should support the `thisArg` argument', 1, function() {
var actual = func(array, function(num, index) {
return -this[index];
}, array);
@@ -4676,6 +4676,13 @@
equal(actual, methodName == 'max' ? 1 : 3);
});
test('`_.' + methodName + '` should work when used as `callback` for `_.map`', 1, function() {
var array = [[2, 3, 1], [5, 6, 4], [8, 9, 7]],
actual = _.map(array, func);
deepEqual(actual, methodName == 'max' ? [3, 6, 9] : [1, 4, 7]);
});
test('`_.' + methodName + '` should iterate an object', 1, function() {
var actual = func({ 'a': 1, 'b': 2, 'c': 3 });
equal(actual, methodName == 'max' ? 3 : 1);