1 import configureStore from 'redux-mock-store';
2 import thunk from 'redux-thunk'
3 import fetchMock from 'fetch-mock';
5 configurableViewsActionTypes
6 } from 'app/configurableViews/ConfigurableViewConstants.js';
8 newCustomComponentsEvent,
10 getConfigurableViewConfigs
11 } from 'app/configurableViews/ConfigurableViewActions.js'
14 describe('ConfigurableViewActionTests', () => {
15 const sampleConfig = {
16 "id": "aggregateReport",
17 "title": "Aggregate Report",
18 "iconURL": "resources/images/sampleAggReportIcon.svg",
19 "iconHoverURL": "resources/images/sampleAggReportIconHover.svg",
20 "viewType": "ConfigurableCardView",
53 "id": "visualization1",
54 "title": "Total VNFs",
56 "eventId": "visualization1",
57 "api": "/get-component-data",
60 "accept": "application/json"
62 "componentDataDescriptor": {
63 "index": "aggregate_generic-vnf_index",
64 "queryType": "aggregation",
70 "name": "prov-status",
73 "field": "prov-status",
79 "name": "orchestration-status",
82 "field": "orchestration-status",
107 "responseTransformation": {
110 "countType": "total",
111 "countResponseLabel": "display"
117 "containerType": "NetworkQueryCard",
118 "visualizationType": "text",
119 "visualizationProp": {
122 "textAlign": "center",
124 "fontWeight": "bold",
153 it('newCustomComponentsEvent', () => {
157 compName: 'Some Name'
160 const middlewares = [thunk];
161 const mockStore = configureStore(middlewares);
162 const store = mockStore({});
163 store.dispatch(newCustomComponentsEvent(components));
164 const actions = store.getActions();
165 expect(actions).toEqual([{
166 type: configurableViewsActionTypes.CUSTOM_COMPONENTS_RECEIVED,
171 it('setCustomRoutes', () => {
174 routeName: 'Some Custom Route',
175 path: 'some/route/path'
178 const middlewares = [thunk];
179 const mockStore = configureStore(middlewares);
180 const store = mockStore({});
181 store.dispatch(setCustomRoutes(routes));
182 const actions = store.getActions();
183 expect(actions).toEqual([{
184 type: configurableViewsActionTypes.CUSTOM_ROUTES,
189 it('getConfigurableViewConfigs', () => {
190 const middlewares = [thunk];
191 const mockStore = configureStore(middlewares);
192 const store = mockStore({});
193 const expectedActions = [
195 type: configurableViewsActionTypes.CONFIGURABLE_VIEWS_CONFIG_RECEIVED,
199 fetchMock.mock('*', sampleConfig);
201 return store.dispatch(getConfigurableViewConfigs())
203 const actions = store.getActions();
204 expect(actions).toEqual(expectedActions);