-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
36 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
npm-debug.log* | ||
node_modules | ||
dist | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
var expect = require('chai').expect; | ||
var find = require('../src/utils').find; | ||
|
||
describe('utility functions', function() { | ||
context('find', function() { | ||
it('returns the value for which the predicate holds true', function() { | ||
var array = [1, 2, 3]; | ||
var value = find(array, function(value) { | ||
return value === 2; | ||
}); | ||
expect(value).to.equal(2); | ||
}); | ||
|
||
it('returns the first value for which the predicate holds true', function() { | ||
var array = [{ key: 1, value: 'one' }, { key: 1, value: 'two' }]; | ||
var value = find(array, function(value) { | ||
return value.key === 1; | ||
}); | ||
expect(value.value).to.equal('one'); | ||
}); | ||
|
||
it('returns undefined if the value is not found', function() { | ||
var array = [1, 2, 3]; | ||
var value = find(array, function(value) { | ||
return value === 4; | ||
}); | ||
expect(value).to.be.undefined; | ||
}); | ||
}); | ||
}); |