completion
This commit is contained in:
34
ioneapps-maagapp-ee31119a522d/__tests__/reducers/settings.js
Normal file
34
ioneapps-maagapp-ee31119a522d/__tests__/reducers/settings.js
Normal file
@@ -0,0 +1,34 @@
|
||||
/* global describe: true, test:true, expect:true */
|
||||
import { settings as settingsReducer, initialState } from '~/reducers/settings';
|
||||
import {
|
||||
GET_SETTINGS_SUCCESS,
|
||||
SET_SETTINGS_SUCCESS,
|
||||
LOGOUT_SUCCESS,
|
||||
} from '~/store/actionTypes';
|
||||
|
||||
describe('settings reducer', () => {
|
||||
test('CASE 1: should return initial state', () => {
|
||||
expect(settingsReducer(undefined, { type: 'Default' }))
|
||||
.toEqual(initialState);
|
||||
});
|
||||
|
||||
test('CASE 2: should empty the state on LOGOUT_SUCCESS', () => {
|
||||
expect(settingsReducer({ languageCode: 'en' }, { type: LOGOUT_SUCCESS }))
|
||||
.toEqual(initialState);
|
||||
});
|
||||
|
||||
test('CASE 3: should return settings on GET_SETTINGS_SUCCESS', () => {
|
||||
const settings = { autoAcceptFriend: true, defaultPlaylistId: 123 };
|
||||
const expectedState = { ...initialState, ...settings };
|
||||
expect(settingsReducer(undefined, { type: GET_SETTINGS_SUCCESS, payload: { settings } }))
|
||||
.toEqual(expectedState);
|
||||
});
|
||||
|
||||
test('CASE 3: should return settings on SET_SETTINGS_SUCCESS', () => {
|
||||
const settings = { defaultPlaylistId: 123 };
|
||||
const existingState = { autoAcceptFriend: false, defaultPlaylistId: -1 };
|
||||
const expectedState = { ...existingState, ...settings };
|
||||
expect(settingsReducer(existingState, { type: SET_SETTINGS_SUCCESS, payload: { settings } }))
|
||||
.toEqual(expectedState);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user