From 5b76d2f720c76b337f609496f864e3d8e15566f6 Mon Sep 17 00:00:00 2001 From: jero Date: Fri, 27 Sep 2019 18:28:05 +0300 Subject: [PATCH] test(footeraction): test against "payload" property improves #35 --- .../actions/{footerData.js => footerAction.js} | 2 +- .../modules/footer/actions/footerAction.test.js | 16 ++++++++++++++++ .../modules/footer/actions/footerData.test.js | 17 ----------------- src/app/store/modules/footer/actions/index.js | 2 +- 4 files changed, 18 insertions(+), 19 deletions(-) rename src/app/store/modules/footer/actions/{footerData.js => footerAction.js} (68%) create mode 100644 src/app/store/modules/footer/actions/footerAction.test.js delete mode 100644 src/app/store/modules/footer/actions/footerData.test.js diff --git a/src/app/store/modules/footer/actions/footerData.js b/src/app/store/modules/footer/actions/footerAction.js similarity index 68% rename from src/app/store/modules/footer/actions/footerData.js rename to src/app/store/modules/footer/actions/footerAction.js index 71fddd7b..7c8d0f8e 100644 --- a/src/app/store/modules/footer/actions/footerData.js +++ b/src/app/store/modules/footer/actions/footerAction.js @@ -3,4 +3,4 @@ import * as types from '@/store/ActionTypes'; import { makeActionCreator } from '@/store/helpers/makeActionCreator'; -export default makeActionCreator(types.FOOTER_DATA, 'footer'); +export default makeActionCreator(types.FOOTER_DATA); diff --git a/src/app/store/modules/footer/actions/footerAction.test.js b/src/app/store/modules/footer/actions/footerAction.test.js new file mode 100644 index 00000000..dde1c3e3 --- /dev/null +++ b/src/app/store/modules/footer/actions/footerAction.test.js @@ -0,0 +1,16 @@ +// @flow strict + +import footerAction from './footerAction'; + +describe('footer action', () => { + it('should return the corresponding \'footer\' object', () => { + const social = [{ id: '0', icon: 'instagram', link: 'https://instagram.com' }]; + const contact = { + phone: '89189258147', + email: 'me@shop.com', + }; + const payload = { footer: { social, contact } }; + const expectedData = { type: 'FOOTER_DATA', payload }; + expect(footerAction(payload)).toEqual(expectedData); + }); +}); diff --git a/src/app/store/modules/footer/actions/footerData.test.js b/src/app/store/modules/footer/actions/footerData.test.js deleted file mode 100644 index cc3f341a..00000000 --- a/src/app/store/modules/footer/actions/footerData.test.js +++ /dev/null @@ -1,17 +0,0 @@ -// @flow strict - -import footerData from './footerData'; - -import type { FooterType } from '@/store/types/FooterType'; - -describe('footerData action', () => { - it('should return the corresponding \'footer\' object', () => { - const social = [{ id: '0', icon: 'instagram', link: 'https://instagram.com' }]; - const contact = { - phone: '89189258147', - email: 'me@shop.com', - }; - const expectedData: FooterType = { type: 'FOOTER_DATA', footer: { social, contact } }; - expect(footerData({ social, contact })).toEqual(expectedData); - }); -}); diff --git a/src/app/store/modules/footer/actions/index.js b/src/app/store/modules/footer/actions/index.js index 1e137a61..ecefdd62 100644 --- a/src/app/store/modules/footer/actions/index.js +++ b/src/app/store/modules/footer/actions/index.js @@ -1,3 +1,3 @@ // @flow strict // eslint-disable-next-line import/prefer-default-export -export { default as footerData } from './footerData'; +export { default as footerAction } from './footerAction';