Skip to content

Commit

Permalink
adds tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Oct 6, 2014
1 parent d208015 commit 20279ad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ module.exports = function forIn(o, fn, thisArg) {
break;
}
}
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "for-in",
"description": "Iterate over the own and inherited enumerable properties of an objecte, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. JavaScript/Node.js",
"version": "0.1.2",
"version": "0.1.3",
"homepage": "https://github.com/jonschlinkert/for-in",
"author": {
"name": "Jon Schlinkert",
Expand Down
17 changes: 17 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,21 @@ describe('.forIn()', function () {
keys.should.eql(['a', 'b', 'c']);
values.should.eql(['foo', 'bar', 'baz']);
});

it('should break the loop early if `false` is returned.', function () {
var obj = {a: 'foo', b: 'bar', c: 'baz'};
var values = [];
var keys = [];

forIn(obj, function (value, key, o) {
if (key === 'b') {
return false;
}
keys.push(key);
values.push(value);
});

keys.should.eql(['a']);
values.should.eql(['foo']);
});
});

0 comments on commit 20279ad

Please sign in to comment.