mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-03 08:37:49 +00:00
Ensure _.callback doesn't error if provided a nullish func argument and a thisArg.
This commit is contained in:
12
test/test.js
12
test/test.js
@@ -1663,6 +1663,18 @@
|
||||
});
|
||||
});
|
||||
|
||||
test('should not error when `func` is nullish and a `thisArg` is provided', 2, function() {
|
||||
var object = {};
|
||||
_.each([null, undefined], function(value) {
|
||||
try {
|
||||
var callback = _.callback(value, {});
|
||||
strictEqual(callback(object), object);
|
||||
} catch(e) {
|
||||
ok(false);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
test('should return a callback created by `_.matches` when `func` is an object', 2, function() {
|
||||
var callback = _.callback({ 'a': 1 });
|
||||
strictEqual(callback({ 'a': 1, 'b': 2 }), true);
|
||||
|
||||
Reference in New Issue
Block a user