Skip to content

Commit

Permalink
Add tests for _.find.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed May 25, 2012
1 parent 7ef6b6d commit e162a68
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions test/collections.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ $(document).ready(function() {
equal(_.reduceRight([], function(){}, undefined), undefined, 'undefined can be passed as a special case');
raises(function() { _.reduceRight([], function(){}); }, TypeError, 'throws an error for empty arrays with no initial value');
});

test('collections: find', function() {
var array = [1, 2, 3, 4];
equal(3, _.find(array, function(n) { return n > 2; }), 'should return first found `value`');
equal(void 0, _.find(array, function() { return false; }), 'should return `undefined` if `value` is not found');
});

test('collections: detect', function() {
var result = _.detect([1, 2, 3], function(num){ return num * 2 == 4; });
Expand Down

0 comments on commit e162a68

Please sign in to comment.