From 7b70b2126de2f360e5d9b7c8cbcd631f9e53c7bb Mon Sep 17 00:00:00 2001 From: typicode Date: Sat, 1 Oct 2016 16:56:18 +0200 Subject: [PATCH] Add tests --- test/test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/test.js b/test/test.js index e796f92..0bc583e 100644 --- a/test/test.js +++ b/test/test.js @@ -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'} ] }; }); @@ -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);