746a3d410c491d952f3d6469ed5abce8797b7737
[aai/sparky-fe.git] / test / vnfSearch / vnfSearchVisualizations / vnfSearchVisualizations.test.js
1 /*
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017 Amdocs
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *       http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  *
21  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  */
23 import React from 'react';
24 import TestUtils from 'react-dom/test-utils';
25 import {storeCreator} from 'app/AppStore.js';
26 import {Provider} from 'react-redux';
27 import { expect } from 'chai';
28 import VnfSearchOrchStatusVisualizations from 'app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx';
29 import VnfSearchProvStatusVisualizations from 'app/vnfSearch/VnfSearchProvStatusVisualization.jsx';
30 import VnfSearchTotalCountVisualization from 'app/vnfSearch/VnfSearchTotalCountVisualization.jsx';
31 import {
32   CHART_PROV_STATUS,
33   CHART_ORCH_STATUS,
34   TOTAL_VNF_COUNT} from 'app/vnfSearch/VnfSearchConstants.js';
35
36 describe('VNF Visualizations Structure Tests', function () {
37
38   function createState(processedOrchStatusCountChartData,
39                        processedProvStatusCountChartData) {
40     return {
41       vnfSearch: {
42         auditVisualizationsData: {
43           processedOrchStatusCountChartData: processedOrchStatusCountChartData,
44           processedProvStatusCountChartData: processedProvStatusCountChartData
45         }
46       }
47     };
48   }
49
50   it('VNF: Visualization layout VNF Orch Status, no data', function () {
51     const store = storeCreator(createState(
52         CHART_ORCH_STATUS.clearingEmptyData,
53         CHART_PROV_STATUS.clearingEmptyData
54     ));
55     this.component = TestUtils.renderIntoDocument(
56         <Provider store={store}>
57           <VnfSearchOrchStatusVisualizations />
58         </Provider>
59     );
60     let visualizationContainer = TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'visualizations');
61     expect(visualizationContainer).to.exist; // there is always a visualizations container
62     expect(visualizationContainer[0].className).to.contain('hidden'); // make sure visualizations is hidden
63   });
64
65   it('VNF: Visualization layout VNF Prov Status, no data', function () {
66     const store = storeCreator(createState(
67         CHART_ORCH_STATUS.clearingEmptyData,
68         CHART_PROV_STATUS.clearingEmptyData
69     ));
70     this.component = TestUtils.renderIntoDocument(
71         <Provider store={store}>
72           <VnfSearchProvStatusVisualizations />
73         </Provider>
74     );
75     let visualizationContainer = TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'visualizations');
76     expect(visualizationContainer).to.exist; // there is always a visualizations container
77     expect(visualizationContainer[0].className).to.contain('hidden'); // make sure visualizations is hidden
78   });
79
80
81   it('VNF: Visualization layout Total VNF, no data', function () {
82     const store = storeCreator(createState(
83         TOTAL_VNF_COUNT.clearingEmptyValue
84     ));
85     this.component = TestUtils.renderIntoDocument(
86         <Provider store={store}>
87           <VnfSearchTotalCountVisualization />
88         </Provider>
89     );
90     let visualizationContainer = TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'visualizations');
91     expect(visualizationContainer).to.exist; // there is always a visualizations container
92     expect(visualizationContainer[0].className).to.contain('hidden'); // make sure visualizations is hidden
93   });
94 });