mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-11 11:27:50 +00:00
Add unit test for passing an object as callback to _.find.
Former-commit-id: 36da6e95473e85ac799180618e1a546d87f0686f
This commit is contained in:
13
test/test.js
13
test/test.js
@@ -556,14 +556,21 @@
|
|||||||
QUnit.module('lodash.find');
|
QUnit.module('lodash.find');
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var array = [1, 2, 3];
|
var array = [
|
||||||
|
{ 'a': 1, 'b': 2, 'c': 3 },
|
||||||
|
{ 'a': 2, 'b': 2, 'c': 3 }
|
||||||
|
];
|
||||||
|
|
||||||
test('should return found `value`', function() {
|
test('should return found `value`', function() {
|
||||||
equal(_.find(array, function(n) { return n > 2; }), 3);
|
equal(_.find(array, function(object) { return object.a == 1; }), array[0]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should return `undefined` if `value` is not found', function() {
|
test('should return `undefined` if `value` is not found', function() {
|
||||||
equal(_.find(array, function(n) { return n == 4; }), undefined);
|
equal(_.find(array, function(object) { return object.a == 3; }), undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('should work with an object for `callback`', function() {
|
||||||
|
equal(_.find(array, { 'b': 2, 'c': 3 }), array[0]);
|
||||||
});
|
});
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user