From c5e4ba5f665db1a63b0b43ba29b44bd5bd8bbb3f Mon Sep 17 00:00:00 2001 From: Juliano Penna Date: Mon, 23 Jan 2017 01:39:54 -0200 Subject: [PATCH] Add config file to DB tests --- server/tests/seed/chatSeed.js | 1 + server/tests/seed/userSeed.js | 1 + server/tests/web/authenticate.test.js | 14 +++++++------- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/server/tests/seed/chatSeed.js b/server/tests/seed/chatSeed.js index 81e8387..da6fed7 100644 --- a/server/tests/seed/chatSeed.js +++ b/server/tests/seed/chatSeed.js @@ -1,3 +1,4 @@ +require('../../config/config'); const { Chat } = require('../../db/model/chat'); const { ObjectId } = require('mongodb'); diff --git a/server/tests/seed/userSeed.js b/server/tests/seed/userSeed.js index 924e539..7ea80fe 100644 --- a/server/tests/seed/userSeed.js +++ b/server/tests/seed/userSeed.js @@ -1,3 +1,4 @@ +require('../../config/config'); const { User } = require('../../db/model/user'); const user1 = { diff --git a/server/tests/web/authenticate.test.js b/server/tests/web/authenticate.test.js index d80e8a2..9a82521 100644 --- a/server/tests/web/authenticate.test.js +++ b/server/tests/web/authenticate.test.js @@ -21,7 +21,7 @@ describe('authenticate', () => { it('should check token cookie', (done) => { request(app) - .get('/views') + .get('/views/chatRoom') .set('Cookie', `token=${token}`) .end((err) => { expect(findUserSpy).toHaveBeenCalled(); @@ -34,8 +34,8 @@ describe('authenticate', () => { findUserSpy.reset(); request(app) - .get('/views') - .expect(401) + .get('/views/chatRoom') + .expect(303) .expect('x-authorization', 'No token cookie') .expect('location', '/views/login') .end((err) => { @@ -48,9 +48,9 @@ describe('authenticate', () => { findUserSpy.andReturn(new Promise(resolve => resolve())); request(app) - .get('/views') + .get('/views/chatRoom') .set('Cookie', `token=${token}`) - .expect(401) + .expect(303) .expect('x-authorization', 'No user found') .expect('location', '/views/login') .end((err) => { @@ -66,9 +66,9 @@ describe('authenticate', () => { })); request(app) - .get('/views') + .get('/views/chatRoom') .set('Cookie', `token=${token}`) - .expect(401) + .expect(303) .expect('x-authorization', 'Token expired') .expect('location', '/views/login') .end((err) => {