-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnavigation.test.js.sample
75 lines (68 loc) · 2.57 KB
/
navigation.test.js.sample
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { expect } from 'chai';
import configureMockStore from 'redux-mock-store';
import sinon from 'sinon';
import thunk from 'redux-thunk';
import fetch from '../../src/utils/fetch';
import types from '../../src/constants/actionTypes';
import * as actions from '../../src/actions/navigate';
import translator from '../../src/utils/I18N';
import BusinessConstants from '../../src/constants/businessConstants';
/* eslint no-unused-expressions:0 */
describe('Navigate Actions', () => {
let sandbox;
let fetchStub;
let fetchGetStub;
const mockStore = configureMockStore([thunk]);
const translation = {
'forces.failed-network': 'abc',
};
beforeEach(() => {
sandbox = sinon.sandbox.create();
fetchStub = sandbox.stub(fetch, 'post');
fetchGetStub = sandbox.stub(fetch, 'get');
sandbox.stub(translator, 'translate', key => translation[key]);
});
afterEach(() => {
sandbox.restore();
});
it('invokes all the calls for event change', () => {
fetchStub.returns(Promise.resolve({ data: { success: 'invoke data call' } }));
fetchGetStub.returns(Promise.resolve({ data: { success: 'invoke data call with get' } }));
const factIdentifier = 12;
const store = mockStore({ stores: [] });
const actionsTypes = [
types.RESET_EVENT_PRICE_VOLUME,
types.RESET_MATCH_COMPETITIVE_POSITIONING,
types.RESET_SELL_THROUGH,
types.PRICING_INFO_SUCCESS,
types.UPDATE_FACT_IDENTIFIER,
types.MATCH_COMPETITIVE_POSITIONING_UPDATED,
types.SELL_THROUGH_DAY_METRICS,
types.SELL_THROUGH_SEASON_METRICS,
types.PRODUCT_PRICES_FOR_SEASON_UPDATED,
types.RESET_COMPETITIVE_PROGRAM,
types.FORCE_BREAKUP_DATA_UPDATED,
types.IN_PRICEPOINT_DATA_SUCCESS,
types.PRE_PRICEPOINT_DATA_SUCCESS,
types.PRODUCT_PRICES_FOR_EVENT_UPDATED,
types.MATCH_COMPETITIVE_PROGRAM_UPDATED,
types.DAY_LEVEL_PRICE_VOLUME,
types.UPDATE_EVENT_PROMOTIONS,
types.PROMOTION_METRICS_UPDATED,
types.DAY_LEVEL_PRICING_UPDATED,
types.DAILY_PROMOTIONS_UPDATED,
types.VALIDATE_PROMOTIONS,
types.INSEASON_MODAL_LOADER,
types.FETCH_EVENT_MEASURES,
types.ROUNDING_RULES_UPDATED,
];
return store.dispatch(actions.fetchDataForInSeasonModal(factIdentifier, 1, 1, 'in', BusinessConstants.SINGLE_RETAIL))
.then(() => {
const allActionsRaised = store.getActions().every((action) => {
const filtered = actionsTypes.filter(act => act === action.type);
return filtered.length >= 1;
});
expect(allActionsRaised).to.be.true;
});
});
});