From dff1dd9eaf0b3c7d655da7e4ef1a53f55589c8b5 Mon Sep 17 00:00:00 2001 From: Nishant Jain Date: Fri, 9 Mar 2018 11:00:09 +0530 Subject: [PATCH] Updated test cases of notes --- api/notes/notes.router.js | 2 +- test/api/notes/notes.router.js | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/api/notes/notes.router.js b/api/notes/notes.router.js index ff4fdb3..d5a4964 100644 --- a/api/notes/notes.router.js +++ b/api/notes/notes.router.js @@ -17,7 +17,7 @@ router.get('/:noteId', async (req, res) => { router.post('/', async (req, res) => { const note = req.body; const createdNote = await notesController.createNote(note); - res.json(JSON.stringify(createdNote)); + res.json(createdNote); }); module.exports = router; diff --git a/test/api/notes/notes.router.js b/test/api/notes/notes.router.js index ea640f7..ee9bd42 100644 --- a/test/api/notes/notes.router.js +++ b/test/api/notes/notes.router.js @@ -32,7 +32,7 @@ describe('Note Routes', () => { should.exist(res.body); res.body.should.be.an.instanceOf(Array); const [noteSample] = res.body; - noteSample.should.have.properties(['title', 'body', 'createdAt', '_id']); + noteSample.should.have.only.keys('title', 'body', 'createdAt', '_id'); done(); }); }); @@ -45,7 +45,7 @@ describe('Note Routes', () => { should.not.exist(err); should.exist(res.body); const noteSample = res.body; - noteSample.should.have.properties(['title', 'body', 'createdAt', '_id']); + noteSample.should.have.only.keys('title', 'body', 'createdAt', '_id'); done(); }); }); @@ -63,8 +63,7 @@ describe('Note Routes', () => { should.not.exist(err); should.exist(res.body); const noteSample = res.body; - console.log(res.body); - noteSample.should.have.properties(['title', 'body', 'createdAt', '_id']); + noteSample.should.have.only.keys('title', 'body', 'createdAt', '_id'); noteSample.title.should.be.exactly('Test Note'); noteSample.body.should.be.exactly('Test Note Body'); done();