2 * ============LICENSE_START=======================================================
3 * SPARKY (AAI UI service)
4 * ================================================================================
5 * Copyright © 2017 AT&T Intellectual Property.
6 * Copyright © 2017 Amdocs
8 * ================================================================================
9 * Licensed under the Apache License, Version 2.0 (the "License");
10 * you may not use this file except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
20 * ============LICENSE_END=========================================================
22 * ECOMP and OpenECOMP are trademarks
23 * and service marks of AT&T Intellectual Property.
26 import React from 'react';
27 import { expect } from 'chai';
28 import reducer from 'app/vnfSearch/vnfSearchVisualizations/VnfSearchVisualizationsReducer.js';
31 CHART_PROV_STATUS, vnfSearchVisualizationsActionTypes} from 'app/vnfSearch/vnfSearchVisualizations/VnfSearchVisualizationsConstants.js';
35 describe('VNF: Audit Visualizations Reducers test suite', function() {
36 const initialState = {
37 processedProvStatusCountChartData: CHART_PROV_STATUS.clearingEmptyData,
38 processedOrchStatusCountChartData: CHART_ORCH_STATUS.clearingEmptyData
40 const initStateWithData = {
41 processedProvStatusCountChartData: [
51 processedOrchStatusCountChartData: [
65 it('VNF: COUNT_BY_ORCH_STATUS_RECEIVED event', function() {
69 { 'x': 'physical-location-id', 'y': 22},
70 { 'x': 'prov-status', 'y': 14},
71 { 'x': 'status-type-3', 'y': 24}
77 type: vnfSearchVisualizationsActionTypes.COUNT_BY_ORCH_STATUS_RECEIVED,
79 orchStatusCountChartData: {
85 const newState = reducer(initialState, action);
86 expect(newState.processedOrchStatusCountChartData[0].values.length).to.equal(3);
87 expect(newState.processedOrchStatusCountChartData[0].values[0]['x']).to.equal('physical-location-id');
88 expect(newState.processedOrchStatusCountChartData[0].values[1]['x']).to.equal('prov-status');
89 expect(newState.processedOrchStatusCountChartData[0].values[2]['x']).to.equal('status-type-3');
90 expect(newState.processedOrchStatusCountChartData[0].values[0]['y']).to.equal(22);
91 expect(newState.processedOrchStatusCountChartData[0].values[1]['y']).to.equal(14);
92 expect(newState.processedOrchStatusCountChartData[0].values[2]['y']).to.equal(24);
95 it('VNF: COUNT_BY_PROV_STATUS_RECEIVED event', function() {
99 { 'x': 'physical-location-id', 'y': 22},
100 { 'x': 'prov-status', 'y': 14},
101 { 'x': 'status-type-3', 'y': 24}
107 type: vnfSearchVisualizationsActionTypes.COUNT_BY_PROV_STATUS_RECEIVED,
109 provStatusCountChartData: {
110 chartData: chartData,
115 const newState = reducer(initialState, action);
116 expect(newState.processedProvStatusCountChartData[0].values.length).to.equal(3);
117 expect(newState.processedProvStatusCountChartData[0].values[0]['x']).to.equal('physical-location-id');
118 expect(newState.processedProvStatusCountChartData[0].values[1]['x']).to.equal('prov-status');
119 expect(newState.processedProvStatusCountChartData[0].values[2]['x']).to.equal('status-type-3');
120 expect(newState.processedProvStatusCountChartData[0].values[0]['y']).to.equal(22);
121 expect(newState.processedProvStatusCountChartData[0].values[1]['y']).to.equal(14);
122 expect(newState.processedProvStatusCountChartData[0].values[2]['y']).to.equal(24);
126 it('VNF: Total VNF event', function() {
130 type: vnfSearchVisualizationsActionTypes.TOTAL_VNF_COUNT_RECEIVED,
134 const newState = reducer(initialState, action);
135 expect(newState.count).to.equal(10);
140 it('VNF: NETWORK_ERROR event', function() {
142 type: vnfSearchVisualizationsActionTypes.VNF_SEARCH_NETWORK_ERROR
144 const newState = reducer(initStateWithData, action);
145 expect(newState.processedProvStatusCountChartData).to.deep.equal(CHART_PROV_STATUS.clearingEmptyData);
146 expect(newState.processedOrchStatusCountChartData).to.deep.equal(CHART_ORCH_STATUS.clearingEmptyData);