diff --git a/src/app/store/helpers/makeActionCreator/makeActionCreator.test.js b/src/app/store/helpers/makeActionCreator/makeActionCreator.test.js index 94f9078a..5c6cc26e 100644 --- a/src/app/store/helpers/makeActionCreator/makeActionCreator.test.js +++ b/src/app/store/helpers/makeActionCreator/makeActionCreator.test.js @@ -3,25 +3,33 @@ import makeActionCreator from './makeActionCreator'; describe('makeActionCreator', () => { const GET_INFO = 'GET_INFO'; - const name = { name: 'Jero' }; + const payload = { user: { name: 'Jero' } }; it('should return an action creator', () => { - const actionCreator = makeActionCreator(GET_INFO, 'user'); + const actionCreator = makeActionCreator(GET_INFO); expect(typeof actionCreator).toBe('function'); }); it('should return an action when calling the action creator', () => { - const actionCreator = makeActionCreator(GET_INFO, 'user'); - const action = actionCreator(name); + const actionCreator = makeActionCreator(GET_INFO); + const action = actionCreator(payload); expect(action).toEqual(expect.objectContaining({ type: GET_INFO })); }); it('should contain action\'s data under "payload" property', () => { - const actionCreator = makeActionCreator(GET_INFO, 'user'); - const action = actionCreator(name); - const payload = { user: name }; + const actionCreator = makeActionCreator(GET_INFO); + const action = actionCreator(payload); const expectedData = { type: GET_INFO, payload }; expect(action).toHaveProperty('payload'); expect(action).toEqual(expectedData); }); + + it('can contain optional "meta" property and its metadata', () => { + const actionCreator = makeActionCreator(GET_INFO); + const meta = { callMe: 'some metada for any purpose' }; + const action = actionCreator(payload, meta); + const expectedData = { type: GET_INFO, payload, meta }; + expect(action).toHaveProperty('meta'); + expect(action).toEqual(expectedData); + }); });