ConfigurableViewReducer test
[aai/sparky-fe.git] / test / app / configurableViews / ConfigurableViewReducer.test.js
1 import {
2   configurableViewsActionTypes
3 } from 'app/configurableViews/ConfigurableViewConstants.js';
4 import ConfigurableViewReducer from 'app/configurableViews/ConfigurableViewReducer.js'
5 describe('ConfigurableViewsReducerTests', () => {
6   it('Action Type: CONFIGURABLE_VIEWS_CONFIG_RECEIVED', () => {
7     // Given
8     const data = {
9       viewId: 'someViewId',
10       viewName: 'Some View Name',
11       viewRoute: 'some/view/route'
12     };
13     const action = {
14       type: configurableViewsActionTypes.CONFIGURABLE_VIEWS_CONFIG_RECEIVED,
15       data: data
16     };
17     let state = {};
18
19     // When
20     state = ConfigurableViewReducer(state, action);
21
22     // Then
23     expect(state).toEqual({
24       configurableViewsConfig: data
25     });
26   });
27
28   it('Action Type: CUSTOM_COMPONENTS_RECEIVED', () => {
29     // Given
30     const data = {
31       componentName: 'someComponentName',
32       componentData: {
33         blah: 'blah',
34         filler: 'filler'
35       }
36     };
37     const action = {
38       type: configurableViewsActionTypes.CUSTOM_COMPONENTS_RECEIVED,
39       data: data
40     };
41     let state = {};
42
43     // When
44     state = ConfigurableViewReducer(state, action);
45
46     // Then
47     expect(state).toEqual({
48       customComponents: data
49     });
50   });
51
52   it('Action Type: CUSTOM_ROUTES', () => {
53     // Given
54     const data = 'some/custom/route';
55     const action = {
56       type: configurableViewsActionTypes.CUSTOM_ROUTES,
57       data: data
58     };
59     let state = {};
60
61     // When
62     state = ConfigurableViewReducer(state, action);
63
64     // Then
65     expect(state).toEqual({
66       customRoutes: data
67     });
68   });
69
70   it('Action Type: unknown', () => {
71     // Given
72     const action = {
73       type: "TestUnknownType",
74       data: "TestData"
75     };
76     let state = {};
77
78     // When
79     state = ConfigurableViewReducer(state, action);
80
81     // Then
82     expect(state).toEqual(state);
83   });
84 });