Last active
July 6, 2021 07:09
-
-
Save manoj-mass/8bda8991519f129acfe061d128331766 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import configureStore from 'redux-mock-store'; | |
import thunk from 'redux-thunk'; | |
import header, { loadHeader, ACTION_TYPES } from 'app/shared/reducers/header'; | |
describe('Header reducer tests', () => { | |
it('should return the initial state', () => { | |
const headerState = header(undefined, {}); | |
expect(headerState).toMatchObject({ | |
headerTitle: '', | |
}); | |
}); | |
it('should correctly detect update in current Header state', () => { | |
const headerState = header(undefined, { type: ACTION_TYPES.SET_HEADERDETAILS, payload: { header: 'header title' } }); | |
expect(headerState).toMatchObject({ headerTitle: headerState.headerTitle }); | |
const updatedHeaderState = header( | |
{ | |
loading: false, | |
headerTitle: 'header title', | |
}, | |
{ type: ACTION_TYPES.SET_HEADERDETAILS, payload: { header: 'header title updated' } } | |
); | |
expect(updatedHeaderState).toMatchObject({ headerTitle: updatedHeaderState.headerTitle }); | |
}); | |
describe('Header actions', () => { | |
it('dispatches SET_HEADERDETAILS actions', () => { | |
const expectedActions = [ | |
{ | |
type: ACTION_TYPES.SET_HEADERDETAILS, | |
payload: { header: 'header title' }, | |
}, | |
]; | |
store.dispatch(loadHeader('header title')); | |
expect(store.getActions()).toEqual(expectedActions); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment