From fa98fa652f41a7c87fe76ab57448ab702e06c82c Mon Sep 17 00:00:00 2001 From: HumairAK Date: Tue, 26 Jul 2016 16:53:35 -0400 Subject: more unit tests --- test/test.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/test.js b/test/test.js index 3b23916..dd47d48 100644 --- a/test/test.js +++ b/test/test.js @@ -207,7 +207,6 @@ describe('Search Route:', function(){ }); - /* Questions Listing route for a particular exam */ describe('Questions Search Route:', function(){ var server; @@ -230,7 +229,7 @@ describe('Questions Search Route:', function(){ }); }); - it.only('Search questions for a non existing exam', function testSlash(done) { + it('Search questions for a non existing exam', function testSlash(done) { var examID = exams.nonExisting._id.$oid; chai.request(server) .get('/questions/' + examID) @@ -244,6 +243,23 @@ describe('Questions Search Route:', function(){ }); }); + /* This differs from the earlier test because it will throw an error in db + * query and not return an exam at all, whereas before we pass in a + * legitimate hashed format id. Here we pass just random letters. + */ + it.only('Search questions for gibberish id', function testSlash(done) { + chai.request(server) + .get('/questions/batman') + .end(function(err, res){ + expect(res).to.have.status(200); + var path = res.res.req.path; + + // Redirected to homepage (with err msg) + assert.equal(path, '/'); + done(); + }); + }); + }); -- cgit v1.2.3