Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored and fixed the frontend test that was failing. #130

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions frontend/src/User/loginActions.unit.spec.js

This file was deleted.

2 changes: 1 addition & 1 deletion frontend/src/User/userActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export function requestLogin(payload) {

export function autoLoginSuccess(user) {
return {
type: UserTypes.LOGIN,
type: UserTypes.AUTO_LOGIN_SUCCESS,
user
};
}
Expand Down
44 changes: 44 additions & 0 deletions frontend/src/User/userActions.unit.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
});
});
5 changes: 4 additions & 1 deletion models/db/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down