2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6 * Copyright © 2017-2018 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 import React from 'react';
22 import { expect } from 'chai';
23 import reducer from 'app/vnfSearch/VnfSearchReducer.js';
26 CHART_PROV_STATUS, vnfSearchVisualizationsActionTypes} from 'app/vnfSearch/VnfSearchConstants.js';
30 describe('VNF: Audit Visualizations Reducers test suite', function() {
31 const initialState = {
32 processedProvStatusCountChartData: CHART_PROV_STATUS.clearingEmptyData,
33 processedOrchStatusCountChartData: CHART_ORCH_STATUS.clearingEmptyData
35 const initStateWithData = {
36 processedProvStatusCountChartData: [
46 processedOrchStatusCountChartData: [
60 it('VNF: COUNT_BY_ORCH_STATUS_RECEIVED event', function() {
64 { 'x': 'physical-location-id', 'y': 22},
65 { 'x': 'prov-status', 'y': 14},
66 { 'x': 'status-type-3', 'y': 24}
72 type: vnfSearchVisualizationsActionTypes.COUNT_BY_ORCH_STATUS_RECEIVED,
74 orchStatusCountChartData: {
80 const newState = reducer(initialState, action);
81 expect(newState.processedOrchStatusCountChartData[0].values.length).to.equal(3);
82 expect(newState.processedOrchStatusCountChartData[0].values[0]['x']).to.equal('physical-location-id');
83 expect(newState.processedOrchStatusCountChartData[0].values[1]['x']).to.equal('prov-status');
84 expect(newState.processedOrchStatusCountChartData[0].values[2]['x']).to.equal('status-type-3');
85 expect(newState.processedOrchStatusCountChartData[0].values[0]['y']).to.equal(22);
86 expect(newState.processedOrchStatusCountChartData[0].values[1]['y']).to.equal(14);
87 expect(newState.processedOrchStatusCountChartData[0].values[2]['y']).to.equal(24);
90 it('VNF: COUNT_BY_PROV_STATUS_RECEIVED event', function() {
94 { 'x': 'physical-location-id', 'y': 22},
95 { 'x': 'prov-status', 'y': 14},
96 { 'x': 'status-type-3', 'y': 24}
102 type: vnfSearchVisualizationsActionTypes.COUNT_BY_PROV_STATUS_RECEIVED,
104 provStatusCountChartData: {
105 chartData: chartData,
110 const newState = reducer(initialState, action);
111 expect(newState.processedProvStatusCountChartData[0].values.length).to.equal(3);
112 expect(newState.processedProvStatusCountChartData[0].values[0]['x']).to.equal('physical-location-id');
113 expect(newState.processedProvStatusCountChartData[0].values[1]['x']).to.equal('prov-status');
114 expect(newState.processedProvStatusCountChartData[0].values[2]['x']).to.equal('status-type-3');
115 expect(newState.processedProvStatusCountChartData[0].values[0]['y']).to.equal(22);
116 expect(newState.processedProvStatusCountChartData[0].values[1]['y']).to.equal(14);
117 expect(newState.processedProvStatusCountChartData[0].values[2]['y']).to.equal(24);
121 it('VNF: Total VNF event', function() {
125 type: vnfSearchVisualizationsActionTypes.TOTAL_VNF_COUNT_RECEIVED,
129 const newState = reducer(initialState, action);
130 expect(newState.count).to.equal(10);
135 it('VNF: NETWORK_ERROR event', function() {
137 type: vnfSearchVisualizationsActionTypes.VNF_SEARCH_NETWORK_ERROR
139 const newState = reducer(initStateWithData, action);
140 expect(newState.processedProvStatusCountChartData).to.deep.equal(CHART_PROV_STATUS.clearingEmptyData);
141 expect(newState.processedOrchStatusCountChartData).to.deep.equal(CHART_ORCH_STATUS.clearingEmptyData);