2 * ============LICENSE_START=======================================================
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
23 import React from 'react';
24 import { expect } from 'chai';
25 import reducer from 'app/vnfSearch/vnfSearchVisualizations/VnfSearchVisualizationsReducer.js';
28 CHART_PROV_STATUS, vnfSearchVisualizationsActionTypes} from 'app/vnfSearch/vnfSearchVisualizations/VnfSearchVisualizationsConstants.js';
32 describe('VNF: Audit Visualizations Reducers test suite', function() {
33 const initialState = {
34 processedProvStatusCountChartData: CHART_PROV_STATUS.clearingEmptyData,
35 processedOrchStatusCountChartData: CHART_ORCH_STATUS.clearingEmptyData
37 const initStateWithData = {
38 processedProvStatusCountChartData: [
48 processedOrchStatusCountChartData: [
62 it('VNF: COUNT_BY_ORCH_STATUS_RECEIVED event', function() {
66 { 'x': 'physical-location-id', 'y': 22},
67 { 'x': 'prov-status', 'y': 14},
68 { 'x': 'status-type-3', 'y': 24}
74 type: vnfSearchVisualizationsActionTypes.COUNT_BY_ORCH_STATUS_RECEIVED,
76 orchStatusCountChartData: {
82 const newState = reducer(initialState, action);
83 expect(newState.processedOrchStatusCountChartData[0].values.length).to.equal(3);
84 expect(newState.processedOrchStatusCountChartData[0].values[0]['x']).to.equal('physical-location-id');
85 expect(newState.processedOrchStatusCountChartData[0].values[1]['x']).to.equal('prov-status');
86 expect(newState.processedOrchStatusCountChartData[0].values[2]['x']).to.equal('status-type-3');
87 expect(newState.processedOrchStatusCountChartData[0].values[0]['y']).to.equal(22);
88 expect(newState.processedOrchStatusCountChartData[0].values[1]['y']).to.equal(14);
89 expect(newState.processedOrchStatusCountChartData[0].values[2]['y']).to.equal(24);
92 it('VNF: COUNT_BY_PROV_STATUS_RECEIVED event', function() {
96 { 'x': 'physical-location-id', 'y': 22},
97 { 'x': 'prov-status', 'y': 14},
98 { 'x': 'status-type-3', 'y': 24}
104 type: vnfSearchVisualizationsActionTypes.COUNT_BY_PROV_STATUS_RECEIVED,
106 provStatusCountChartData: {
107 chartData: chartData,
112 const newState = reducer(initialState, action);
113 expect(newState.processedProvStatusCountChartData[0].values.length).to.equal(3);
114 expect(newState.processedProvStatusCountChartData[0].values[0]['x']).to.equal('physical-location-id');
115 expect(newState.processedProvStatusCountChartData[0].values[1]['x']).to.equal('prov-status');
116 expect(newState.processedProvStatusCountChartData[0].values[2]['x']).to.equal('status-type-3');
117 expect(newState.processedProvStatusCountChartData[0].values[0]['y']).to.equal(22);
118 expect(newState.processedProvStatusCountChartData[0].values[1]['y']).to.equal(14);
119 expect(newState.processedProvStatusCountChartData[0].values[2]['y']).to.equal(24);
123 it('VNF: Total VNF event', function() {
127 type: vnfSearchVisualizationsActionTypes.TOTAL_VNF_COUNT_RECEIVED,
131 const newState = reducer(initialState, action);
132 expect(newState.count).to.equal(10);
137 it('VNF: NETWORK_ERROR event', function() {
139 type: vnfSearchVisualizationsActionTypes.VNF_SEARCH_NETWORK_ERROR
141 const newState = reducer(initStateWithData, action);
142 expect(newState.processedProvStatusCountChartData).to.deep.equal(CHART_PROV_STATUS.clearingEmptyData);
143 expect(newState.processedOrchStatusCountChartData).to.deep.equal(CHART_ORCH_STATUS.clearingEmptyData);