Add _.invoke tests.

This commit is contained in:
John-David Dalton
2014-12-09 09:19:41 -08:00
parent 0904724694
commit d393349b4d

View File

@@ -5495,12 +5495,21 @@
deepEqual(_.invoke(array, 'toUpperCase'), ['A', 'B', 'C']); deepEqual(_.invoke(array, 'toUpperCase'), ['A', 'B', 'C']);
}); });
test('should work with a function `methodName` argument', 1, function() { test('should support invoking with arguments', 1, function() {
var actual = _.invoke(['a', 'b', 'c'], function() { var array = [function() { return slice.call(arguments); }],
return this.toUpperCase(); actual = _.invoke(array, 'call', null, 'a', 'b', 'c');
deepEqual(actual, [['a', 'b', 'c']]);
}); });
deepEqual(actual, ['A', 'B', 'C']); test('should work with a function `methodName` argument', 1, function() {
var array = ['a', 'b', 'c'];
var actual = _.invoke(array, function(left, right) {
return left + this.toUpperCase() + right;
}, '(', ')');
deepEqual(actual, ['(A)', '(B)', '(C)']);
}); });
test('should work with an object for `collection`', 1, function() { test('should work with an object for `collection`', 1, function() {