Skip to content

Commit

Permalink
Add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
typicode committed Oct 1, 2016
1 parent 11c3dfa commit 7b70b21
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ Object.keys(libs).forEach(function(name) {
comments: [
{id: 1, body: 'foo', postId: 1},
{id: 2, body: 'bar', postId: 2}
],
authors: [
{id: '1', name: 'foo'},
{id: '2', name: 'bar'}
]
};
});
Expand Down Expand Up @@ -57,6 +61,20 @@ Object.keys(libs).forEach(function(name) {
assert.deepEqual(doc, expect);
});

it('returns doc by id with string param', function() {
var expect = db.posts[0],
doc = _.getById(db.posts, '1');

assert.deepEqual(doc, expect);
});

it('returns doc by id with string id', function() {
var expect = db.authors[0],
doc = _.getById(db.authors, 1);

assert.deepEqual(doc, expect);
});

it('returns undefined if doc is not found', function() {
var doc = _.getById(db.posts, 9999);

Expand Down

0 comments on commit 7b70b21

Please sign in to comment.