1 import fetchMock from 'fetch-mock';
2 import expect from 'expect';
3 import {InventoryActionTypes} from "app/inventory/InventoryConstants";
4 import reducer from 'app/inventory/InventoryReducer';
8 function verifyStateProducedByReducer(action, currentState, expectedState) {
10 const actual = reducer(currentState, action);
13 expect(actual).toEqual(expectedState);
16 describe('InventoryReducer', () => {
22 it('verify store state after TOPOGRAPHIC_QUERY_SUCCESS action', async () => {
26 type: InventoryActionTypes.TOPOGRAPHIC_QUERY_SUCCESS,
35 const expectedState = {
44 const currentState = {state: "dummy"};
46 verifyStateProducedByReducer(action, currentState, expectedState);
50 it('verify store state after COUNT_BY_ENTITY_SUCCESS action', async () => {
54 type: InventoryActionTypes.COUNT_BY_ENTITY_SUCCESS,
63 const expectedState = {
71 const currentState = {state: "dummy"};
73 verifyStateProducedByReducer(action, currentState, expectedState);
77 it('verify store state after COUNT_BY_DATE_SUCCESS action', async () => {
81 type: InventoryActionTypes.COUNT_BY_DATE_SUCCESS,
90 const expectedState = {
98 const currentState = {state: "dummy"};
100 verifyStateProducedByReducer(action, currentState, expectedState);
103 it('verify store state after TOPOGRAPHIC_QUERY_FAILED action', async () => {
107 type: InventoryActionTypes.TOPOGRAPHIC_QUERY_FAILED,
110 message: "Some error occurred"
114 const expectedState = {
116 feedbackMsgSeverity: "ERROR",
117 feedbackMsgText: "Some error occurred"
121 const currentState = {state: "dummy"};
123 verifyStateProducedByReducer(action, currentState, expectedState);
126 it('verify store state after COUNT_BY_ENTITY_FAILED action', async () => {
130 type: InventoryActionTypes.COUNT_BY_ENTITY_FAILED,
133 message: "Some error occurred"
137 const expectedState = {
139 feedbackMsgSeverity: "ERROR",
140 feedbackMsgText: "Some error occurred"
144 const currentState = {state: "dummy"};
146 verifyStateProducedByReducer(action, currentState, expectedState);
149 it('verify store state after COUNT_BY_DATE_FAILED action', async () => {
153 type: InventoryActionTypes.COUNT_BY_DATE_FAILED,
156 message: "Some error occurred"
160 const expectedState = {
162 feedbackMsgSeverity: "ERROR",
163 feedbackMsgText: "Some error occurred"
167 const currentState = {state: "dummy"};
169 verifyStateProducedByReducer(action, currentState, expectedState);
172 it('verify store state after unknown action', async () => {
179 const expectedState = {state: "dummy"};
181 const currentState = {state: "dummy"};
183 verifyStateProducedByReducer(action, currentState, expectedState);