completion
This commit is contained in:
73
ioneapps-maagapp-ee31119a522d/__tests__/reducers/user.js
Normal file
73
ioneapps-maagapp-ee31119a522d/__tests__/reducers/user.js
Normal file
@@ -0,0 +1,73 @@
|
||||
/* global describe: true, test:true, expect:true */
|
||||
import { user } from '~/reducers/user';
|
||||
import {
|
||||
SUBMIT_LOGIN_SUCCESS,
|
||||
LOGOUT_SUCCESS,
|
||||
} from '~/store/actionTypes';
|
||||
|
||||
|
||||
describe('user reducer', () => {
|
||||
test('CASE 1: should return initial state', () => {
|
||||
const expectedState = {
|
||||
checkUserStorage: false,
|
||||
showLanguageChangedDialog: false,
|
||||
enableLanguageDiscrepancyPopup: false,
|
||||
displayUploadDialogue: true,
|
||||
showStorageFull: false,
|
||||
showLanguageDiscrepancy: false,
|
||||
meta: { loading: false, error: '' },
|
||||
isFullStoragePopup: false,
|
||||
todo: {
|
||||
avatar: {
|
||||
avatarChanged: true,
|
||||
tutorialDismissed: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(user(undefined, {}))
|
||||
.toEqual(expectedState);
|
||||
});
|
||||
|
||||
test('CASE 2: should return correct state when actionType is `SUBMIT_LOGIN_SUCCESS`', () => {
|
||||
const expectedState = {
|
||||
token: 'token',
|
||||
username: 'username',
|
||||
email: 'email@email.com',
|
||||
firstName: 'first',
|
||||
lastName: 'last',
|
||||
checkUserStorage: true,
|
||||
meta: { loading: false, error: '' },
|
||||
isFullStoragePopup: false,
|
||||
todo: {
|
||||
avatar: {
|
||||
avatarChanged: true,
|
||||
tutorialDismissed: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(user({}, { type: SUBMIT_LOGIN_SUCCESS, payload: { user: expectedState } }))
|
||||
.toEqual(expectedState);
|
||||
});
|
||||
|
||||
test('CASE 3: should return correct state when actionType is `LOGOUT_SUCCESS`', () => {
|
||||
const enableLanguageDiscrepancyPopup = false;
|
||||
const expectedState = {
|
||||
checkUserStorage: false,
|
||||
displayUploadDialogue: true,
|
||||
showLanguageChangedDialog: false,
|
||||
enableLanguageDiscrepancyPopup,
|
||||
showStorageFull: false,
|
||||
showLanguageDiscrepancy: false,
|
||||
meta: { loading: false, error: '' },
|
||||
isFullStoragePopup: false,
|
||||
todo: {
|
||||
avatar: {
|
||||
avatarChanged: true,
|
||||
tutorialDismissed: false,
|
||||
},
|
||||
},
|
||||
};
|
||||
expect(user({ enableLanguageDiscrepancyPopup }, { type: LOGOUT_SUCCESS, payload: { user: expectedState } }))
|
||||
.toEqual(expectedState);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user