Remove unused code
[aai/sparky-fe.git] / test / app / vnfSearch / VnfSearchTotalCountVisualization.test.js
1 import React from 'react';
2 import { shallow, mount } from 'enzyme';
3 import {Provider} from 'react-redux'
4 import configureStore from 'redux-mock-store';
5
6 import ConnectedVnfSearchTotalCountVisualization,
7   { VnfSearchTotalCountVisualization } from 'app/vnfSearch/VnfSearchTotalCountVisualization.jsx';
8 import { TOTAL_VNF_COUNT } from 'app/vnfSearch/VnfSearchConstants.js';
9 import Spinner from 'utils/SpinnerContainer';
10
11 describe('VnfSearchTotalCountVisualization - Shallow render of component', () => {
12   let wrapper;
13   const countProp = 25;
14
15   beforeEach( () => {
16     wrapper = shallow(
17       <VnfSearchTotalCountVisualization
18         enableBusyFeedback={false}
19         count={countProp}
20       />
21     );
22   })
23
24   it('Render basic component', () => {
25     expect(wrapper.length).toEqual(1);
26     expect(wrapper.hasClass('visualizations')).toEqual(true);
27   });
28
29   it('Verify Spinner is present but not visible', () => {
30     expect(wrapper.find(Spinner)).toHaveLength(1);
31     expect(wrapper.find(Spinner).props().loading).toEqual(false);
32   });
33
34   it('Verify total count is displayed', () => {
35     expect(wrapper.contains(<span>{countProp}</span>)).toBe(true);
36   });
37 })
38
39 describe('VnfSearchTotalCountVisualization - Shallow render of component with no chart data', () => {
40   let wrapper;
41   const countProp = null;
42
43   beforeEach( () => {
44     wrapper = shallow(
45       <VnfSearchTotalCountVisualization
46         enableBusyFeedback={false}
47         count={countProp}
48       />
49     );
50   })
51
52   it('Visualization graph hidden', () => {
53     expect(wrapper.length).toEqual(1);
54     expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true);
55   });
56 })
57
58 describe('VnfSearchTotalCountVisualization - Shallow render of component with busy feedback', () => {
59   let wrapper;
60   const countProp = 25;
61
62   beforeEach( () => {
63     wrapper = shallow(
64       <VnfSearchTotalCountVisualization
65         enableBusyFeedback={true}
66         count={countProp}
67       />
68     );
69   })
70
71   it('Render basic component', () => {
72     expect(wrapper.length).toEqual(1);
73     expect(wrapper.hasClass('visualizations')).toEqual(true);
74   });
75
76   it('Verify Spinner is present and visible', () => {
77     expect(wrapper.find(Spinner)).toHaveLength(1);
78     expect(wrapper.find(Spinner).props().loading).toEqual(true);
79   });
80
81   it('Verify total count is displayed', () => {
82     expect(wrapper.contains(<span>{countProp}</span>)).toBe(true);
83   });
84 })
85
86 describe('VnfSearchTotalCountVisualization - Render React Component (wrapped in <Provider>)', () => {
87   const initialState = {
88     vnfSearch: {
89       count: 25,
90       enableBusyFeedback: false
91     }
92   };
93   const mockStore = configureStore();
94   let store, wrapper;
95
96   beforeEach( () => {
97     store = mockStore(initialState);
98     wrapper = mount(<Provider store={store}><ConnectedVnfSearchTotalCountVisualization /></Provider>);
99   })
100
101   it('Render the connected component', () => {
102     expect(wrapper.find(ConnectedVnfSearchTotalCountVisualization).length).toEqual(1);
103   });
104
105   it('Validate props from store', () => {
106     expect(wrapper.find(VnfSearchTotalCountVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback);
107     expect(wrapper.find(VnfSearchTotalCountVisualization).props().count).toEqual(initialState.vnfSearch.count);
108   });
109 })
110
111 describe('VnfSearchTotalCountVisualization - Render React Component (wrapped in <Provider>) with default props', () => {
112   const initialState = {
113     vnfSearch: {}
114   };
115   const mockStore = configureStore();
116   let store, wrapper;
117
118   beforeEach( () => {
119     store = mockStore(initialState);
120     wrapper = mount(<Provider store={store}><ConnectedVnfSearchTotalCountVisualization /></Provider>);
121   })
122
123   it('Render the connected component', () => {
124     expect(wrapper.find(ConnectedVnfSearchTotalCountVisualization).length).toEqual(1);
125   });
126
127   it('Validate default props loaded', () => {
128     expect(wrapper.find(VnfSearchTotalCountVisualization).props().enableBusyFeedback).toEqual(false);
129     expect(wrapper.find(VnfSearchTotalCountVisualization).props().count).toEqual(TOTAL_VNF_COUNT.emptyValue);
130   });
131 })