diff --git a/frontend/src/User/loginActions.unit.spec.js b/frontend/src/User/loginActions.unit.spec.js deleted file mode 100644 index f875af9..0000000 --- a/frontend/src/User/loginActions.unit.spec.js +++ /dev/null @@ -1,49 +0,0 @@ -import { expect } from 'chai'; -import * as actions from './userActions'; -import * as UserTypes from './UserTypes'; - -describe('login actions', () => { - const user = { email: 'e@g.com', name: 'e' }; - it('should create an action when login successful', () => { - const expectedAction = { - type: UserTypes.REQUEST_LOGIN_SUCCESS, - user - }; - expect(actions.requestLoginSuccess(user)).to.eql(expectedAction); - }); - it('should create an action when login fails', () => { - const error = 'some error'; - const expectedAction = { - type: UserTypes.REQUEST_LOGIN_FAILED, - error - }; - expect(actions.requestLoginFailed(error)).to.eql(expectedAction); - }); - it('should create an action when error cleared', () => { - const expectedAction = { - type: UserTypes.CLEAR_LOGIN_ERROR - }; - expect(actions.clearLoginError()).to.eql(expectedAction); - }); - it('should create an action when auto login successful', () => { - const expectedAction = { - type: UserTypes.AUTO_LOGIN_SUCCESS, - user - }; - expect(actions.autoLoginSuccess(user)).to.eql(expectedAction); - }); - it('should create an action when auto login fails', () => { - const error = 'some error'; - const expectedAction = { - type: UserTypes.AUTO_LOGIN_FAILED, - error - }; - expect(actions.autoLoginFailed(error)).to.eql(expectedAction); - }); - it('should create an action when logout requested', () => { - const expectedAction = { - type: UserTypes.LOGOUT - }; - expect(actions.requestLogout()).to.eql(expectedAction); - }); -}); diff --git a/frontend/src/User/userActions.js b/frontend/src/User/userActions.js index 9381251..866fb98 100644 --- a/frontend/src/User/userActions.js +++ b/frontend/src/User/userActions.js @@ -51,7 +51,7 @@ export function requestLogin(payload) { export function autoLoginSuccess(user) { return { - type: UserTypes.LOGIN, + type: UserTypes.AUTO_LOGIN_SUCCESS, user }; } diff --git a/frontend/src/User/userActions.unit.spec.js b/frontend/src/User/userActions.unit.spec.js index 84f8613..1a08e58 100644 --- a/frontend/src/User/userActions.unit.spec.js +++ b/frontend/src/User/userActions.unit.spec.js @@ -2,6 +2,8 @@ import { expect } from 'chai'; import * as actions from './userActions'; import * as UserTypes from './UserTypes'; +const USER = { email: 'e@g.com', name: 'e' }; + describe('user actions', () => { it('should create an action when working', () => { const isWorking = true; @@ -35,4 +37,46 @@ describe('user actions', () => { }; expect(actions.userSuccess(user)).to.eql(expectedAction); }); + it('should create an action when login successful', () => { + const expectedAction = { + type: UserTypes.REQUEST_LOGIN_SUCCESS, + user: USER + }; + expect(actions.requestLoginSuccess(USER)).to.eql(expectedAction); + }); + it('should create an action when login fails', () => { + const error = 'some error'; + const expectedAction = { + type: UserTypes.REQUEST_LOGIN_FAILED, + error + }; + expect(actions.requestLoginFailed(error)).to.eql(expectedAction); + }); + it('should create an action when error cleared', () => { + const expectedAction = { + type: UserTypes.CLEAR_LOGIN_ERROR + }; + expect(actions.clearLoginError()).to.eql(expectedAction); + }); + it('should create an action when auto login successful', () => { + const expectedAction = { + type: UserTypes.AUTO_LOGIN_SUCCESS, + user: USER + }; + expect(actions.autoLoginSuccess(USER)).to.eql(expectedAction); + }); + it('should create an action when auto login fails', () => { + const error = 'some error'; + const expectedAction = { + type: UserTypes.AUTO_LOGIN_FAILED, + error + }; + expect(actions.autoLoginFailed(error)).to.eql(expectedAction); + }); + it('should create an action when logout requested', () => { + const expectedAction = { + type: UserTypes.LOGOUT + }; + expect(actions.requestLogout()).to.eql(expectedAction); + }); }); diff --git a/models/db/db.js b/models/db/db.js index d27bdb9..f6524e4 100644 --- a/models/db/db.js +++ b/models/db/db.js @@ -5,7 +5,10 @@ mongoose.Promise = global.Promise; const config = require('./config'); async function init() { - await mongoose.connect(config.uri); + await mongoose.connect( + config.uri, + { useNewUrlParser: true } + ); } async function close() {