1 import React from 'react';
2 import { shallow, mount } from 'enzyme';
3 import {Provider} from 'react-redux'
4 import configureStore from 'redux-mock-store';
6 import ConnectedVnfSearchTotalCountVisualization,
7 { VnfSearchTotalCountVisualization } from './VnfSearchTotalCountVisualization.jsx';
8 import { TOTAL_VNF_COUNT } from './VnfSearchConstants.js';
9 import Spinner from 'utils/SpinnerContainer.jsx';
11 describe('VnfSearchTotalCountVisualization - Shallow render of component', () => {
17 <VnfSearchTotalCountVisualization
18 enableBusyFeedback={false}
24 it('Render basic component', () => {
25 expect(wrapper.length).toEqual(1);
26 expect(wrapper.hasClass('visualizations')).toEqual(true);
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);
34 it('Verify total count is displayed', () => {
35 expect(wrapper.contains(<span>{countProp}</span>)).toBe(true);
39 describe('VnfSearchTotalCountVisualization - Shallow render of component with no chart data', () => {
41 const countProp = null;
45 <VnfSearchTotalCountVisualization
46 enableBusyFeedback={false}
52 it('Visualization graph hidden', () => {
53 expect(wrapper.length).toEqual(1);
54 expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true);
58 describe('VnfSearchTotalCountVisualization - Shallow render of component with busy feedback', () => {
64 <VnfSearchTotalCountVisualization
65 enableBusyFeedback={true}
71 it('Render basic component', () => {
72 expect(wrapper.length).toEqual(1);
73 expect(wrapper.hasClass('visualizations')).toEqual(true);
76 it('Verify Spinner is present and visible', () => {
77 expect(wrapper.find(Spinner)).toHaveLength(1);
78 expect(wrapper.find(Spinner).props().loading).toEqual(true);
81 it('Verify total count is displayed', () => {
82 expect(wrapper.contains(<span>{countProp}</span>)).toBe(true);
86 describe('VnfSearchTotalCountVisualization - Render React Component (wrapped in <Provider>)', () => {
87 const initialState = {
90 enableBusyFeedback: false
93 const mockStore = configureStore();
97 store = mockStore(initialState);
98 wrapper = mount(<Provider store={store}><ConnectedVnfSearchTotalCountVisualization /></Provider>);
101 it('Render the connected component', () => {
102 expect(wrapper.find(ConnectedVnfSearchTotalCountVisualization).length).toEqual(1);
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);
111 describe('VnfSearchTotalCountVisualization - Render React Component (wrapped in <Provider>) with default props', () => {
112 const initialState = {
115 const mockStore = configureStore();
119 store = mockStore(initialState);
120 wrapper = mount(<Provider store={store}><ConnectedVnfSearchTotalCountVisualization /></Provider>);
123 it('Render the connected component', () => {
124 expect(wrapper.find(ConnectedVnfSearchTotalCountVisualization).length).toEqual(1);
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);