summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteve Thomas <steventh@amdocs.com>2018-03-29 14:41:43 -0400
committerSteven Thomas <steve.thomas@amdocs.com>2018-03-29 14:57:35 -0400
commit0b2b11bad1457e7f388ab2a99af6ebf231e862e3 (patch)
tree8ef541c5b172893ca9b952cf251a7a78668ab6f1 /test
parent47b85e9b95e0a0a3570f0cea4d3ee4645c911a8b (diff)
increasing test coverage to 10%
Issue-ID: AAI-980 Change-Id: Idb816df11fa14b5668349f24bac1aafd7235e00a Signed-off-by: Steven Thomas <steve.thomas@amdocs.com>
Diffstat (limited to 'test')
-rw-r--r--test/components/dateRange.test.js259
-rw-r--r--test/components/dateRangeSelector.test.js303
-rw-r--r--test/components/inlineMessage.test.js90
-rw-r--r--test/components/notificationReducer.test.js108
-rw-r--r--test/components/toggleButtonGroupReducer.test.js41
-rw-r--r--test/fileMock.js1
-rw-r--r--test/setupTests.js5
-rw-r--r--test/styleMock.js1
-rw-r--r--test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBar.test.js313
-rw-r--r--test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarActions.test.js259
-rw-r--r--test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarReducer.test.js136
-rw-r--r--test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarTestConstants.js231
-rw-r--r--test/tierSupport/tierSupport.test.js35
-rw-r--r--test/utils/MockRest.js85
-rw-r--r--test/vnfSearch/vnfSearchVisualizations/vnfSearchVisualizations.test.js92
-rw-r--r--test/vnfSearch/vnfSearchVisualizations/vnfSearchVisualizationsReducer.test.js144
16 files changed, 7 insertions, 2096 deletions
diff --git a/test/components/dateRange.test.js b/test/components/dateRange.test.js
deleted file mode 100644
index 161a57a..0000000
--- a/test/components/dateRange.test.js
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-import React from 'react';
-import TestUtils from 'react-dom/test-utils';
-import {Provider} from 'react-redux';
-import {expect} from 'chai';
-import i18n from 'utils/i18n/i18n';
-
-import store from 'app/AppStore.js';
-import DateRange from 'generic-components/dateRange/DateRange.jsx';
-import {
- dateRangeActionTypes,
- LABEL_START_DATE,
- LABEL_END_DATE,
- DATE_PICKER_PLACEHOLDER,
- IS_AFTER_END_DATE,
- IS_BEFORE_START_DATE,
- END_DATE,
- START_DATE} from 'generic-components/dateRange/DateRangeConstants.js';
-import DateRangeActions from 'generic-components/dateRange/DateRangeActions.js';
-import reducer from 'generic-components/dateRange/DateRangeReducer.js';
-import sinon from 'sinon';
-
-import { moment } from 'moment';
-
-describe('Core Date Range suite', function() {
-
- beforeEach(function() {
- this.component = TestUtils.renderIntoDocument(<Provider store={store}><DateRange /></Provider>);
- });
-
- // test structure
- it('Date Range - Validate start & end lables', function() {
- let labels = TestUtils.scryRenderedDOMComponentsWithTag(this.component, 'label');
- expect(labels.length).to.equal(2);
- expect(labels[0].textContent).to.equal(LABEL_START_DATE + ': ');
- expect(labels[1].textContent).to.equal(LABEL_END_DATE + ': ');
- });
-
- it('Date Range - Start Date Picker exists', function() {
- let datePicker = TestUtils.findRenderedDOMComponentWithClass(this.component, 'start-date-picker');
- expect(datePicker).to.exist;
- expect(datePicker.type).to.equal('text');
- expect(datePicker.placeholder).to.equal(DATE_PICKER_PLACEHOLDER);
- });
-
- it('Date Range - End Date Picker exists', function() {
- let datePicker = TestUtils.findRenderedDOMComponentWithClass(this.component, 'end-date-picker');
- expect(datePicker).to.exist;
- expect(datePicker.type).to.equal('text');
- expect(datePicker.placeholder).to.equal(DATE_PICKER_PLACEHOLDER);
- });
-
- // Reducer Tests
- it('Date Range Reducer ... set start date (no initial dates)', function() {
- var moment = require('moment');
- const initialState = {};
- const dateChangeAction = {type: dateRangeActionTypes.DATE_RANGE_CHANGE, data: {dateRange: {startDate: moment(new Date('05/04/2016'))}, errorMsg: ''}};
- const newState = reducer(initialState, dateChangeAction);
- expect(newState.dateRangeStart).to.exist;
- expect(newState.dateRangeStart.toDate().getTime()).to.equal(new Date('05/04/2016').getTime());
- expect(newState.dateRangeEnd).to.not.exist;
- expect(newState.dateRangeError).to.equal('');
- });
- it('Date Range Reducer ... update start date (no end date)', function() {
- var moment = require('moment');
- const initialStartDate = new Date('05/01/2016');
- const initialState = {dateRange: {startDate: moment(initialStartDate)}};
- const dateChangeAction = {type: dateRangeActionTypes.DATE_RANGE_CHANGE, data: {dateRange: {startDate: moment(new Date('05/04/2016'))}, errorMsg: ''}};
- const newState = reducer(initialState, dateChangeAction);
- expect(newState.dateRangeStart).to.exist;
- expect(newState.dateRangeStart.toDate().getTime()).to.equal(new Date('05/04/2016').getTime());
- expect(newState.dateRangeEnd).to.not.exist;
- expect(newState.dateRangeError).to.equal('');
- });
- it('Date Range Reducer - set end date (no start date)', function() {
- var moment = require('moment');
- const initialState = {};
- const dateChangeAction = {type: dateRangeActionTypes.DATE_RANGE_CHANGE, data: {dateRange: {endDate: moment(new Date('05/04/2016'))}, errorMsg: ''}};
- const newState = reducer(initialState, dateChangeAction);
- expect(newState.dateRangeEnd).to.exist;
- expect(newState.dateRangeEnd.toDate().getTime()).to.equal(new Date('05/04/2016').getTime());
- expect(newState.dateRangeStart).to.not.exist;
- expect(newState.dateRangeError).to.equal('');
- });
- it('Date Range Reducer - update end date (no start date)', function() {
- var moment = require('moment');
- const initialEndDate = new Date('05/01/2016');
- const initialState = {dateRange: {endDate: moment(initialEndDate)}};
- const dateChangeAction = {type: dateRangeActionTypes.DATE_RANGE_CHANGE, data: {dateRange: {endDate: moment(new Date('05/04/2016'))}, errorMsg: ''}};
- const newState = reducer(initialState, dateChangeAction);
- expect(newState.dateRangeEnd).to.exist;
- expect(newState.dateRangeEnd.toDate().getTime()).to.equal(new Date('05/04/2016').getTime());
- expect(newState.dateRangeStart).to.not.exist;
- expect(newState.dateRangeError).to.equal('');
- });
- it('Date Range Reducer - set end date with initial start date', function() {
- var moment = require('moment');
- const initialStartDate = new Date('05/01/2016');
- const initialState = {dateRange: {startDate: moment(initialStartDate)}};
- const dateChangeAction = {type: dateRangeActionTypes.DATE_RANGE_CHANGE, data: {dateRange: {startDate: moment(new Date('05/01/2016')), endDate: moment(new Date('05/04/2016'))}, errorMsg: ''}};
- const newState = reducer(initialState, dateChangeAction);
- expect(newState.dateRangeStart).to.exist;
- expect(newState.dateRangeStart.toDate().getTime()).to.equal(new Date('05/01/2016').getTime());
- expect(newState.dateRangeEnd).to.exist;
- expect(newState.dateRangeEnd.toDate().getTime()).to.equal(new Date('05/04/2016').getTime());
- expect(newState.dateRangeError).to.equal('');
- });
- it('Date Range Reducer - set start date with initial end date', function() {
- var moment = require('moment');
- const initialEndDate = new Date('05/04/2016');
- const initialState = {dateRange: {endDate: moment(initialEndDate)}};
- const dateChangeAction = {type: dateRangeActionTypes.DATE_RANGE_CHANGE, data: {dateRange: {startDate: moment(new Date('05/01/2016')), endDate: moment(new Date('05/04/2016'))}, errorMsg: ''}};
- const newState = reducer(initialState, dateChangeAction);
- expect(newState.dateRangeStart).to.exist;
- expect(newState.dateRangeStart.toDate().getTime()).to.equal(new Date('05/01/2016').getTime());
- expect(newState.dateRangeEnd).to.exist;
- expect(newState.dateRangeEnd.toDate().getTime()).to.equal(new Date('05/04/2016').getTime());
- expect(newState.dateRangeError).to.equal('');
- });
- it('Date Range Reducer - verify INVALID_DATE_RANGE event', function() {
- var moment = require('moment');
- const errMsg = 'Some error message';
- const initialEndDate = new Date('05/01/2016');
- const initialStartDate = new Date('05/02/2016');
- const initialState = {startDate: moment(initialStartDate), endDate: moment(initialEndDate)};
- const invalidRangeAction = {type: dateRangeActionTypes.INVALID_DATE_RANGE, data: {dateRange: {startDate: moment(initialStartDate), endDate: moment(initialEndDate)}, errorMsg: errMsg}};
- const newState = reducer(initialState, invalidRangeAction);
- expect(newState.endDate.toDate().getTime()).to.equal(new Date('05/01/2016').getTime());
- expect(newState.startDate.toDate().getTime()).to.equal(new Date('05/02/2016').getTime());
- expect(newState.dateRangeError).to.equal(errMsg);
- });
-
- // test Actions
- it('Date Range Action - valid start date change', function() {
- var moment = require('moment');
- const startDate = moment(new Date('07/19/2016'));
- const endDate = moment(new Date('07/20/2016'));
- const expectedAction = {
- type: dateRangeActionTypes.DATE_RANGE_CHANGE,
- data: {
- dateRange: {
- startDate: startDate,
- endDate: endDate
- },
- }
-
- };
- const results = DateRangeActions.onStartDateChange(startDate, endDate);
-
- expect(results.type).to.equal(expectedAction.type);
- expect(results.data.dateRange.startDate).to.equal(expectedAction.data.dateRange.startDate);
- expect(results.data.dateRange.endDate).to.equal(expectedAction.data.dateRange.endDate);
- });
- it('Date Range Action - valid end date change', function() {
- var moment = require('moment');
- const startDate = moment(new Date('07/19/2016'));
- const endDate = moment(new Date('07/20/2016'));
- const expectedAction = {
- type: dateRangeActionTypes.DATE_RANGE_CHANGE,
- data: {
- dateRange: {
- startDate: startDate,
- endDate: endDate
- },
- }
-
- };
- const results = DateRangeActions.onEndDateChange(startDate, endDate);
-
- expect(results.type).to.equal(expectedAction.type);
- expect(results.data.dateRange.startDate).to.equal(expectedAction.data.dateRange.startDate);
- expect(results.data.dateRange.endDate).to.equal(expectedAction.data.dateRange.endDate);
- });
- it('Date Range Action - end date before start date', function() {
- var moment = require('moment');
- const startDate = moment(new Date('07/21/2016'));
- const endDate = moment(new Date('07/20/2016'));
- const errorMsg = i18n(END_DATE) + ': ' +
- moment(new Date(endDate)).format(DATE_PICKER_PLACEHOLDER) +
- ' ' + i18n(IS_BEFORE_START_DATE);
- const expectedAction = {
- type: dateRangeActionTypes.INVALID_DATE_RANGE,
- data: {
- dateRange: {
- startDate: startDate,
- endDate: endDate
- },
- errorMsg: errorMsg
- }
-
- };
- const results = DateRangeActions.onEndDateChange(startDate, endDate);
-
- expect(results.type).to.equal(expectedAction.type);
- expect(results.data.dateRange.startDate).to.equal(expectedAction.data.dateRange.startDate);
- expect(results.data.dateRange.endDate).to.equal(expectedAction.data.dateRange.endDate);
- expect(results.data.errorMsg).to.equal(expectedAction.data.errorMsg);
- });
- it('Date Range Action - start date after date', function() {
- var moment = require('moment');
- const startDate = moment(new Date('07/21/2016'));
- const endDate = moment(new Date('07/20/2016'));
- const errorMsg = i18n(START_DATE) + ': ' +
- moment(new Date(startDate)).format(DATE_PICKER_PLACEHOLDER) +
- ' ' + i18n(IS_AFTER_END_DATE);
- const expectedAction = {
- type: dateRangeActionTypes.INVALID_DATE_RANGE,
- data: {
- dateRange: {
- startDate: startDate,
- endDate: endDate
- },
- errorMsg: errorMsg
- }
-
- };
- const results = DateRangeActions.onStartDateChange(startDate, endDate);
-
- expect(results.type).to.equal(expectedAction.type);
- expect(results.data.dateRange.startDate).to.equal(expectedAction.data.dateRange.startDate);
- expect(results.data.dateRange.endDate).to.equal(expectedAction.data.dateRange.endDate);
- expect(results.data.errorMsg).to.equal(expectedAction.data.errorMsg);
- });
- it('Date Range Action - confirm onStartDateChange action called on startDate change', function() {
- const spy = sinon.spy(DateRangeActions, 'onStartDateChange');
- let startDatePicker = TestUtils.findRenderedDOMComponentWithClass(this.component, 'start-date-picker');
- startDatePicker.value = '05/09/2016';
- TestUtils.Simulate.change(startDatePicker);
- expect(DateRangeActions.onStartDateChange.calledOnce).to.be.true;
- DateRangeActions.onStartDateChange.restore();
- });
- it('Date Range Action - confirm onEndDateChange action called on endDate change', function() {
- const spy = sinon.spy(DateRangeActions, 'onEndDateChange');
- let endDatePicker = TestUtils.findRenderedDOMComponentWithClass(this.component, 'end-date-picker');
- endDatePicker.value = '05/09/2016';
- TestUtils.Simulate.change(endDatePicker);
- expect(DateRangeActions.onEndDateChange.calledOnce).to.be.true;
- DateRangeActions.onEndDateChange.restore();
- });
-});
diff --git a/test/components/dateRangeSelector.test.js b/test/components/dateRangeSelector.test.js
deleted file mode 100644
index 134d6c6..0000000
--- a/test/components/dateRangeSelector.test.js
+++ /dev/null
@@ -1,303 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-import React from "react";
-import TestUtils from "react-dom/test-utils";
-import {Provider} from "react-redux";
-import {expect} from "chai";
-import {moment} from "moment";
-import store from "app/AppStore.js";
-import DateRangeSelector from "generic-components/dateRangeSelector/DateRangeSelector.jsx";
-import DateRangeSelectorActions from "generic-components/dateRangeSelector/DateRangeSelectorActions.js";
-import {
- dateRangeSelectorActionTypes,
- TODAY,
- YESTERDAY,
- LAST_WEEK,
- LAST_MONTH,
- CUSTOM,
- ICON_CLASS_CALENDAR,
- ICON_CLASS_DOWN_CARET,
- ERROR_UNKNOWN_PERIOD} from "generic-components/dateRangeSelector/DateRangeSelectorConstants.js";
-import reducer from "generic-components/dateRangeSelector/DateRangeSelectorReducer.js";
-import {dateRangeActionTypes, DATE_PICKER_PLACEHOLDER} from "generic-components/dateRange/DateRangeConstants.js";
-import {MESSAGE_LEVEL_DANGER} from "utils/GlobalConstants.js";
-
-describe("Date Range Selector Test Suite", function() {
-
- beforeEach(function () {
- this.component = TestUtils.renderIntoDocument( <Provider store={store}><DateRangeSelector /></Provider>);
- });
-
- // test structure
- it("Date Range Selector - Validate selector button", function () {
- var moment = require('moment');
- let currentDate = moment(new Date()).format(DATE_PICKER_PLACEHOLDER);
- let button = TestUtils.findRenderedDOMComponentWithTag(this.component, 'button');
- expect(button).exists;
- expect(button.childNodes.length).to.equal(3);
- expect(button.childNodes[0].className).to.have.string(ICON_CLASS_CALENDAR);
- expect(button.childNodes[1].innerHTML).to.have.string(currentDate + ' - ' + currentDate);
- expect(button.childNodes[2].className).to.have.string(ICON_CLASS_DOWN_CARET);
- });
-
- it("Date Range Selector - Validate quick pick options", function () {
- let button = TestUtils.findRenderedDOMComponentWithTag(this.component, 'button');
- TestUtils.Simulate.click(button);
-
- let popoverMenu = document.body.getElementsByClassName('popover-content');
- // TODO - need to figure out how to get the popover menu (above doesn't work)
- });
-
- // test reducer
- it("Date Range Selector Reducer ... Vaidate DATE_RANGE_CHANGE event)", function() {
- var moment = require('moment');
- const initialState = {
- startDate: moment(new Date('07/20/2016')),
- endDate: moment(new Date('07/09/2016')),
- period: CUSTOM,
- periodErrText: 'some error text',
- periodErrSev: 'some error severity'
- };
- const rangeChangeAction = {
- type: dateRangeActionTypes.DATE_RANGE_CHANGE,
- data: {
- dateRange: {
- startDate: moment(new Date('05/04/2016')),
- endDate: moment(new Date('06/05/2016'))
- },
- errorMsg: ''
- }};
- const newState = reducer(initialState, rangeChangeAction);
- expect(newState.startDate).to.exist;
- expect(newState.startDate.toDate().getTime()).to.equal(new Date('05/04/2016').getTime());
- expect(newState.endDate).to.exist;
- expect(newState.endDate.toDate().getTime()).to.equal(new Date('06/05/2016').getTime());
- expect(newState.period).to.equal(CUSTOM);
- expect(newState.periodErrText).to.equal('');
- expect(newState.periodErrSev).to.equal('');
- });
- it("Date Range Selector Reducer ... Vaidate INVALID_DATE_RANGE event)", function() {
- var moment = require('moment');
- const initialState = {};
- const rangeChangeAction = {
- type: dateRangeActionTypes.INVALID_DATE_RANGE,
- data: {
- dateRange: {
- startDate: moment(new Date('07/04/2016')),
- endDate: moment(new Date('06/05/2016'))
- },
- errorMsg: 'some eror message'
- }};
- const newState = reducer(initialState, rangeChangeAction);
- expect(newState.startDate).to.exist;
- expect(newState.startDate.toDate().getTime()).to.equal(new Date('07/04/2016').getTime());
- expect(newState.endDate).to.exist;
- expect(newState.endDate.toDate().getTime()).to.equal(new Date('06/05/2016').getTime());
- expect(newState.period).to.not.exist;
- expect(newState.periodErrText).to.equal('some eror message');
- expect(newState.periodErrSev).to.equal(MESSAGE_LEVEL_DANGER);
- });
- it("Date Range Selector Reducer ... Vaidate PERIOD_CHANGE event)", function() {
- var moment = require('moment');
- const initialState = {
- startDate: moment(new Date('07/20/2016')),
- endDate: moment(new Date('07/09/2016')),
- period: CUSTOM,
- periodErrText: 'some error text',
- periodErrSev: 'some error severity'
- };
- const rangeChangeAction = {
- type: dateRangeSelectorActionTypes.EVENT_PERIOD_CHANGE,
- data: {
- dateRange: {
- startDate: moment(new Date('07/04/2016')),
- endDate: moment(new Date('07/05/2016'))
- },
- period: YESTERDAY
- }
- };
- const newState = reducer(initialState, rangeChangeAction);
- expect(newState.startDate).to.exist;
- expect(newState.startDate.toDate().getTime()).to.equal(new Date('07/04/2016').getTime());
- expect(newState.endDate).to.exist;
- expect(newState.endDate.toDate().getTime()).to.equal(new Date('07/05/2016').getTime());
- expect(newState.period).to.equal(YESTERDAY);
- expect(newState.periodErrText).to.equal('');
- expect(newState.periodErrSev).to.equal('');
- });
-
- // test Actions
- it("Date Range Selector Action - test EVENT_PERIOD_CHANGE (period = Today)", function() {
- var moment = require('moment');
- const startDate = moment(new Date());
- const endDate = moment(new Date());
- const period = TODAY;
-
- const results = DateRangeSelectorActions.onPeriodChange(startDate, endDate, period);
-
- const expectedStartTime = moment(new Date());
- setTime(expectedStartTime, 0, 0, 0);
- const expectedEndTime = moment(new Date());
- setTime(expectedEndTime, 23, 59, 59);
- const expectedAction = buildExpectedPeriodChangeAction(expectedStartTime, expectedEndTime, TODAY);
-
- expect(results.type).to.equal(expectedAction.type);
- validateDates(results.data.dateRange.startDate, expectedAction.data.dateRange.startDate);
- validateDates(results.data.dateRange.endDate, expectedAction.data.dateRange.endDate);
- expect(results.data.period).to.equal(expectedAction.data.period);
- });
- it("Date Range Selector Action - test EVENT_PERIOD_CHANGE (period = Yesterday)", function() {
- var moment = require('moment');
- const startDate = moment(new Date());
- const endDate = moment(new Date());
- const period = YESTERDAY;
-
- const results = DateRangeSelectorActions.onPeriodChange(startDate, endDate, period);
-
- const expectedStartTime = moment(new Date()).subtract(1, 'days');
- setTime(expectedStartTime, 0, 0, 0);
- const expectedEndTime = moment(new Date());
- setTime(expectedEndTime, 23, 59, 59);
- const expectedAction = buildExpectedPeriodChangeAction(expectedStartTime, expectedEndTime, YESTERDAY);
-
- expect(results.type).to.equal(expectedAction.type);
- validateDates(results.data.dateRange.startDate, expectedAction.data.dateRange.startDate);
- validateDates(results.data.dateRange.endDate, expectedAction.data.dateRange.endDate);
- expect(results.data.period).to.equal(expectedAction.data.period);
- });
- it("Date Range Selector Action - test EVENT_PERIOD_CHANGE (period = Last Week)", function() {
- var moment = require('moment');
- const startDate = moment(new Date());
- const endDate = moment(new Date());
- const period = LAST_WEEK;
-
- const results = DateRangeSelectorActions.onPeriodChange(startDate, endDate, period);
-
- const expectedStartTime = moment(new Date()).subtract(7, 'days');
- setTime(expectedStartTime, 0, 0, 0);
- const expectedEndTime = moment(new Date());
- setTime(expectedEndTime, 23, 59, 59);
- const expectedAction = buildExpectedPeriodChangeAction(expectedStartTime, expectedEndTime, LAST_WEEK);
-
- expect(results.type).to.equal(expectedAction.type);
- validateDates(results.data.dateRange.startDate, expectedAction.data.dateRange.startDate);
- validateDates(results.data.dateRange.endDate, expectedAction.data.dateRange.endDate);
- expect(results.data.period).to.equal(expectedAction.data.period);
- });
- it("Date Range Selector Action - test EVENT_PERIOD_CHANGE (period = Last Month)", function() {
- var moment = require('moment');
- const startDate = moment(new Date());
- const endDate = moment(new Date());
- const period = LAST_MONTH;
-
- const results = DateRangeSelectorActions.onPeriodChange(startDate, endDate, period);
-
- const expectedStartTime = moment(new Date()).subtract(1, 'months');
- setTime(expectedStartTime, 0, 0, 0);
- const expectedEndTime = moment(new Date());
- setTime(expectedEndTime, 23, 59, 59);
- const expectedAction = buildExpectedPeriodChangeAction(expectedStartTime, expectedEndTime, LAST_MONTH);
-
- expect(results.type).to.equal(expectedAction.type);
- validateDates(results.data.dateRange.startDate, expectedAction.data.dateRange.startDate);
- validateDates(results.data.dateRange.endDate, expectedAction.data.dateRange.endDate);
- expect(results.data.period).to.equal(expectedAction.data.period);
- });
- it("Date Range Selector Action - test EVENT_PERIOD_CHANGE (period = Custom)", function() {
- var moment = require('moment');
- const startDate = moment(new Date()).subtract(3, 'months');
- const endDate = moment(new Date()).add(6, 'days');
- const period = CUSTOM;
-
- const results = DateRangeSelectorActions.onPeriodChange(startDate, endDate, period);
-
- setTime(startDate, 0, 0, 0);
- setTime(endDate, 23, 59, 59);
- const expectedAction = buildExpectedPeriodChangeAction(startDate, endDate, CUSTOM);
-
- expect(results.type).to.equal(expectedAction.type);
- validateDates(results.data.dateRange.startDate, expectedAction.data.dateRange.startDate);
- validateDates(results.data.dateRange.endDate, expectedAction.data.dateRange.endDate);
- expect(results.data.period).to.equal(expectedAction.data.period);
- });
- it("Date Range Selector Action - test EVENT_PERIOD_CHANGE (period = Unknown)", function() {
- var moment = require('moment');
- const startDate = moment(new Date()).subtract(3, 'months');
- const endDate = moment(new Date()).add(6, 'days');
- const period = 'Some Unknown Period';
-
- const results = DateRangeSelectorActions.onPeriodChange(startDate, endDate, period);
-
- let expectedErrorMsg = ERROR_UNKNOWN_PERIOD + ': ' + period;
- const expectedAction = buildExpectedUnknownPeriodAction(startDate, endDate, period, expectedErrorMsg);
-
- expect(results.type).to.deep.equal(expectedAction.type);
- validateDates(results.data.dateRange.startDate, expectedAction.data.dateRange.startDate);
- validateDates(results.data.dateRange.endDate, expectedAction.data.dateRange.endDate);
- expect(results.data.period).to.equal(expectedAction.data.period);
- });
-
- // TODO - need tests to confirm DateRangeSelectorActions.onPeriodChange is called when clicking any of the 'quick link' periods
-
-
- // helper functions
- function setTime(moment, hours, minutes, seconds) {
- moment.toDate();
- moment.hour(hours);
- moment.minute(minutes);
- moment.second(seconds);
- }
-
- function validateDates(actualDate, expectedDates) {
- expect(actualDate.toDate().getYear()).to.equal(expectedDates.toDate().getYear());
- expect(actualDate.toDate().getMonth()).to.equal(expectedDates.toDate().getMonth());
- expect(actualDate.toDate().getDay()).to.equal(expectedDates.toDate().getDay());
- expect(actualDate.toDate().getHours()).to.equal(expectedDates.toDate().getHours());
- expect(actualDate.toDate().getMinutes()).to.equal(expectedDates.toDate().getMinutes());
- }
-
- function buildExpectedPeriodChangeAction(start, end, period) {
- return {
- type: dateRangeSelectorActionTypes.EVENT_PERIOD_CHANGE,
- data: {
- dateRange: {
- startDate: start,
- endDate: end
- },
- period: period
- }
- };
- }
-
- function buildExpectedUnknownPeriodAction(start, end, period, errorMsg) {
- return {
- type: dateRangeSelectorActionTypes.EVENT_PERIOD_ERROR,
- data: {
- dateRange: {
- startDate: start,
- endDate: end
- },
- period: period,
- errorMsg: errorMsg
- }
- };
- }
-});
diff --git a/test/components/inlineMessage.test.js b/test/components/inlineMessage.test.js
deleted file mode 100644
index b56a97f..0000000
--- a/test/components/inlineMessage.test.js
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-import { expect } from 'chai';
-import React from 'react';
-import TestUtils from 'react-dom/test-utils';
-import InlineMessage from 'generic-components/InlineMessage/InlineMessage.jsx';
-import InlineMessageConstants from 'generic-components/InlineMessage/InlineMessageConstants.js';
-
-describe('Core Inline Message Suite', function() {
-
- let _successMessage;
- let _warningMessage;
- let _dangerMessage;
- let _defaultMessage;
-
- beforeEach(function() {
- _warningMessage = TestUtils.renderIntoDocument(<InlineMessage level='warning' messageTxt='Warning Message' />);
- _successMessage = TestUtils.renderIntoDocument(<InlineMessage level='success' messageTxt='Success Message' />);
- _dangerMessage = TestUtils.renderIntoDocument(<InlineMessage level='danger' messageTxt='Danger Message' />);
- _defaultMessage = TestUtils.renderIntoDocument(<InlineMessage level='info' messageTxt='Info Message' />);
- });
-
- // test structure
- it('Inline Message - validate success message panel', function() {
- let alertPanel = TestUtils.findRenderedDOMComponentWithClass(_successMessage, 'alert');
- expect(alertPanel).to.exist; // alert panel exists
- let alertPanel_style = TestUtils.findRenderedDOMComponentWithClass(_successMessage, 'alert-success');
- expect(alertPanel_style).to.exist; // alert panel has proper styling
- let messagePanel = TestUtils.findRenderedDOMComponentWithClass(_successMessage, InlineMessageConstants.MESSAGE_PANEL_CLASSNAME);
- expect(messagePanel).to.exist;
- expect(messagePanel.innerHTML).to.have.string('Success Message'); // messagePanel panel has proper message
- let iconPanel = TestUtils.findRenderedDOMComponentWithClass(_successMessage, InlineMessageConstants.ICON_PANEL_CLASSNAME);
- expect(iconPanel).to.exist;
- expect(iconPanel.innerHTML).to.have.string(InlineMessageConstants.SUCCESS_CLASSNAME); // notification panel has proper styling
- });
- it('Inline Message - validate info message panel', function() {
- let alertPanel = TestUtils.findRenderedDOMComponentWithClass(_defaultMessage, 'alert');
- expect(alertPanel).to.exist; // alert panel exists
- let alertPanel_style = TestUtils.findRenderedDOMComponentWithClass(_defaultMessage, 'alert-info');
- expect(alertPanel_style).to.exist; // alert panel has proper styling
- let messagePanel = TestUtils.findRenderedDOMComponentWithClass(_defaultMessage, InlineMessageConstants.MESSAGE_PANEL_CLASSNAME);
- expect(messagePanel).to.exist;
- expect(messagePanel.innerHTML).to.have.string('Info Message'); // messagePanel panel has proper message
- let iconPanel = TestUtils.findRenderedDOMComponentWithClass(_defaultMessage, InlineMessageConstants.ICON_PANEL_CLASSNAME);
- expect(iconPanel).to.exist;
- expect(iconPanel.innerHTML).to.have.string(InlineMessageConstants.DEFAULT_CLASSNAME); // icon panel has proper styling
- });
- it('Inline Message - validate warning message panel', function() {
- let alertPanel = TestUtils.findRenderedDOMComponentWithClass(_warningMessage, 'alert');
- expect(alertPanel).to.exist; // alert panel exists
- let alertPanel_style = TestUtils.findRenderedDOMComponentWithClass(_warningMessage, 'alert-warning');
- expect(alertPanel_style).to.exist; // alert panel has proper styling
- let messagePanel = TestUtils.findRenderedDOMComponentWithClass(_warningMessage, InlineMessageConstants.MESSAGE_PANEL_CLASSNAME);
- expect(messagePanel).to.exist;
- expect(messagePanel.innerHTML).to.have.string('Warning Message'); // messagePanel panel has proper message
- let iconPanel = TestUtils.findRenderedDOMComponentWithClass(_warningMessage, InlineMessageConstants.ICON_PANEL_CLASSNAME);
- expect(iconPanel).to.exist;
- expect(iconPanel.innerHTML).to.have.string(InlineMessageConstants.WARNING_CLASSNAME); // icon panel has proper styling
- });
- it('Inline Message - validate danger message panel', function() {
- let alertPanel = TestUtils.findRenderedDOMComponentWithClass(_dangerMessage, 'alert');
- expect(alertPanel).to.exist; // alert panel exists
- let alertPanel_style = TestUtils.findRenderedDOMComponentWithClass(_dangerMessage, 'alert-danger');
- expect(alertPanel_style).to.exist; // alert panel has proper styling
- let messagePanel = TestUtils.findRenderedDOMComponentWithClass(_dangerMessage, InlineMessageConstants.MESSAGE_PANEL_CLASSNAME);
- expect(messagePanel).to.exist;
- expect(messagePanel.innerHTML).to.have.string('Danger Message'); // messagePanel panel has proper message
- let iconPanel = TestUtils.findRenderedDOMComponentWithClass(_dangerMessage, InlineMessageConstants.ICON_PANEL_CLASSNAME);
- expect(iconPanel).to.exist;
- expect(iconPanel.innerHTML).to.have.string(InlineMessageConstants.DANGER_CLASSNAME); // icon panel has proper styling
- });
-});
diff --git a/test/components/notificationReducer.test.js b/test/components/notificationReducer.test.js
deleted file mode 100644
index 9600a82..0000000
--- a/test/components/notificationReducer.test.js
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-import { expect } from 'chai';
-import NotificationConstants from 'generic-components/notifications/NotificationConstants.js';
-import reducer from 'generic-components/notifications/NotificationReducer.js';
-
-describe("Notification reducer test suite", function() {
- const initialState = {
- title: '',
- msg: '',
- timeout: 0
- };
-
- it("NOTIFY_INFO event", function() {
- const action = {
- type: NotificationConstants.NOTIFY_INFO,
- data: {
- title: 'some title',
- msg: 'some message',
- timeout: 1
- }
- }
- const newState = reducer(initialState, action);
-
- expect(newState.type).to.equal('default');
- expect(newState.title).to.equal('some title');
- expect(newState.msg).to.equal('some message');
- expect(newState.timeout).to.equal(1);
- });
-
- it("NOTIFY_ERROR event", function() {
- const action = {
- type: NotificationConstants.NOTIFY_ERROR,
- data: {
- title: 'some title',
- msg: 'some message',
- timeout: 1
- }
- }
- const newState = reducer(initialState, action);
-
- expect(newState.type).to.equal('error');
- expect(newState.title).to.equal('some title');
- expect(newState.msg).to.equal('some message');
- expect(newState.timeout).to.equal(1);
- });
-
- it("NOTIFY_WARNING event", function() {
- const action = {
- type: NotificationConstants.NOTIFY_WARNING,
- data: {
- title: 'some title',
- msg: 'some message',
- timeout: 1
- }
- }
- const newState = reducer(initialState, action);
-
- expect(newState.type).to.equal('warning');
- expect(newState.title).to.equal('some title');
- expect(newState.msg).to.equal('some message');
- expect(newState.timeout).to.equal(1);
- });
-
- it("NOTIFY_SUCCESS event", function() {
- const action = {
- type: NotificationConstants.NOTIFY_SUCCESS,
- data: {
- title: 'some title',
- msg: 'some message',
- timeout: 1
- }
- }
- const newState = reducer(initialState, action);
-
- expect(newState.type).to.equal('success');
- expect(newState.title).to.equal('some title');
- expect(newState.msg).to.equal('some message');
- expect(newState.timeout).to.equal(1);
- });
-
- it("NOTIFY_CLOSE event", function() {
- const action = {
- type: NotificationConstants.NOTIFY_CLOSE
- }
- const newState = reducer(initialState, action);
-
- expect(newState).to.be.null;
- });
-});
diff --git a/test/components/toggleButtonGroupReducer.test.js b/test/components/toggleButtonGroupReducer.test.js
deleted file mode 100644
index 93ddaf9..0000000
--- a/test/components/toggleButtonGroupReducer.test.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-import { expect } from 'chai';
-import {BUTTON_TOGGLED} from 'generic-components/toggleButtonGroup/ToggleButtonGroupConstants.js';
-import reducer from 'generic-components/toggleButtonGroup/ToggleButtonGroupReducer.js';
-
-describe("Toggle Button Group reducer test suite", function() {
- const initialState = {
- selectedButton: ''
- };
-
- it("BUTTON_TOGGLED event", function () {
- const action = {
- type: BUTTON_TOGGLED,
- data: {
- button: 'some button name'
- }
- }
- const newState = reducer(initialState, action);
-
- expect(newState.selectedButton).to.equal('some button name');
- });
-});
diff --git a/test/fileMock.js b/test/fileMock.js
new file mode 100644
index 0000000..86059f3
--- /dev/null
+++ b/test/fileMock.js
@@ -0,0 +1 @@
+module.exports = 'test-file-stub';
diff --git a/test/setupTests.js b/test/setupTests.js
new file mode 100644
index 0000000..7237dc9
--- /dev/null
+++ b/test/setupTests.js
@@ -0,0 +1,5 @@
+import { configure } from 'enzyme';
+import Adapter from 'enzyme-adapter-react-15';
+import 'jest-enzyme';
+
+configure({ adapter: new Adapter() });
diff --git a/test/styleMock.js b/test/styleMock.js
new file mode 100644
index 0000000..f053ebf
--- /dev/null
+++ b/test/styleMock.js
@@ -0,0 +1 @@
+module.exports = {};
diff --git a/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBar.test.js b/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBar.test.js
deleted file mode 100644
index dc4ebf4..0000000
--- a/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBar.test.js
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-import {expect, deep} from 'chai';
-import React from 'react';
-import {Provider} from 'react-redux';
-import sinon from 'sinon';
-import configureStore from 'redux-mock-store';
-import thunk from 'redux-thunk';
-import {storeCreator} from 'app/AppStore.js';
-import TestUtils from 'react-dom/test-utils';
-import {
- autoCompleteSearchBarActionTypes,
- ERROR_INVALID_SEARCH_TERMS,
- TS_BACKEND_SEARCH_SELECTED_NODE_URL,
- NO_MATCHES_FOUND
-} from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBarConstants.js';
-import {AutoCompleteSearchBar} from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBar.jsx';
-import {ERROR_RETRIEVING_DATA, POST, POST_HEADER} from 'app/networking/NetworkConstants.js';
-import {tierSupportActionTypes, TSUI_SEARCH_URL} from 'app/tierSupport/TierSupportConstants.js';
-
-import {mount, shallow} from 'enzyme';
-import i18n from 'utils/i18n/i18n';
-import {
- queryRequestedValues,
- clearSuggestionsTextField,
- onSuggestionsChange,
- onSuggestionsClearRequested,
- querySelectedNodeElement,
- getInvalidSearchInputEvent
-} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions.js';
-import * as networkCall from 'app/networking/NetworkCalls.js';
-import autoCompleteSearchBarTestConstants from './autoCompleteSearchBarTestConstants';
-
-const middlewares = [thunk]; // add your middlewares like `redux-thunk`
-const mockStore = configureStore(middlewares);
-
-
-describe('Core AutoCompleteSearchBar suite', function() {
-
- describe('AutoCompleteSearchBar - View test ', function() {
- let wrapper = undefined;
-
- beforeEach(() => {
- wrapper = mount(
- <AutoCompleteSearchBar
- onSuggestionsFetchRequested={() => {}}
- value=''
- suggestions={[]}
- cachedSuggestions={[]}
- feedbackMsgText=''
- feedbackMsgSeverity=''
- />
- );
- });
-
- function createState(currentScreen, tierSupport) {
- return {
- currentScreen: currentScreen,
- tierSupport: tierSupport
- };
- }
-
-
-
- it('Test flow - test onNewSearch() success test: Expect tierSupportActionTypes.TS_NODE_SEARCH_RESULTS action being passed When the selected node is found in the main database and e', done => {
- const mStore = mockStore({});
- let mockNetwork = sinon.mock(networkCall);
- mockNetwork.expects('fetchRequest').once().withArgs(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword).returns(Promise.resolve(autoCompleteSearchBarTestConstants.validResponseJsonForNodeSearchFromFetchWithHits));
- let mockedNetworkFetchRequest = () => networkCall.fetchRequest(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword);
- wrapper.setProps({
- value: autoCompleteSearchBarTestConstants.nodeSearchKeyword,
- suggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits,
- cachedSuggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits,
- onNewSearch: (searchRequestObject, value) => {
- if (Object.keys(searchRequestObject).length === 0) {
- mStore.dispatch(getInvalidSearchInputEvent(autoCompleteSearchBarTestConstants.nodeSearchKeyword));
- } else {
- mStore.dispatch(querySelectedNodeElement(searchRequestObject, autoCompleteSearchBarTestConstants.nodeSearchKeyword, mockedNetworkFetchRequest));
- }
- }
-
- });
-
- function onSucessfullNodeDetailsFoundEvent(){
- return {
- type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS,
- data: autoCompleteSearchBarTestConstants.validResponseJsonForNodeSearchFromFetchWithHits
- };
- }
- wrapper.find('.auto-complete-search-button').simulate('click');
- mockNetwork.verify();
- mockNetwork.restore();
- setTimeout(() => expect(mStore.getActions()[0]).to.deep.equal(onSucessfullNodeDetailsFoundEvent()), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- });
-
- it('Test flow - test onNewSearch() failure test: Expect tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS action being passed When the selected node is not found in the main database and e', done => {
-
- const mStore = mockStore({});
- let mockNetwork = sinon.mock(networkCall);
- mockNetwork.expects('fetchRequest').once().withArgs(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword).returns(Promise.resolve(autoCompleteSearchBarTestConstants.inValidResponseJsonForNodeSearchFromFetchWithHits));
- let mockedNetworkFetchRequest = () => networkCall.fetchRequest(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword);
- wrapper.setProps({
- value: autoCompleteSearchBarTestConstants.nodeSearchKeyword,
- suggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits,
- cachedSuggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits,
- onNewSearch: (searchRequestObject, value) => {
- if (Object.keys(searchRequestObject).length === 0) {
- mStore.dispatch(getInvalidSearchInputEvent(autoCompleteSearchBarTestConstants.nodeSearchKeyword));
- } else {
- mStore.dispatch(querySelectedNodeElement(searchRequestObject, autoCompleteSearchBarTestConstants.nodeSearchKeyword, mockedNetworkFetchRequest));
- }
- }
-
- });
-
- function onNofullNodeDetailsFoundEvent(){
- return {
- type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS,
- data: {searchTag: autoCompleteSearchBarTestConstants.nodeSearchKeyword}
- };
- }
- wrapper.find('.auto-complete-search-button').simulate('click');
- mockNetwork.verify();
- mockNetwork.restore();
- setTimeout(() => {
- expect(mStore.getActions()[0]).to.deep.equal(onNofullNodeDetailsFoundEvent()), autoCompleteSearchBarTestConstants.mockRequestTimeOut;
- });
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- });
-
- it('Test flow - test onNewSearch() failure: Expect tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR action being passed When Network fails', done => {
- const mStore = mockStore({});
- let mockNetwork = sinon.mock(networkCall);
- mockNetwork.expects('fetchRequest').once().withArgs(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword).returns(Promise.resolve(autoCompleteSearchBarTestConstants.networkError));
- let mockedNetworkFetchRequest = () => networkCall.fetchRequest(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword);
- wrapper.setProps({
- value: autoCompleteSearchBarTestConstants.nodeSearchKeyword,
- suggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits,
- cachedSuggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits,
- onNewSearch: (searchRequestObject, value) => {
- if (Object.keys(searchRequestObject).length === 0) {
- mStore.dispatch(getInvalidSearchInputEvent(autoCompleteSearchBarTestConstants.nodeSearchKeyword));
- } else {
- mStore.dispatch(querySelectedNodeElement(searchRequestObject, autoCompleteSearchBarTestConstants.nodeSearchKeyword, mockedNetworkFetchRequest));
- }
- }
-
- });
-
- function onInvalidSelectedNodeSearchEvent(){
- return {
- type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR,
- data: {value: autoCompleteSearchBarTestConstants.nodeSearchKeyword, errorMsg: ERROR_RETRIEVING_DATA}
- };
- }
- wrapper.find('.auto-complete-search-button').simulate('click');
- mockNetwork.verify();
- mockNetwork.restore();
- setTimeout(() => {
- expect(mStore.getActions()[0]).to.deep.equal(onInvalidSelectedNodeSearchEvent()), autoCompleteSearchBarTestConstants.mockRequestTimeOut;
- });
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- });
-
-
- it('Test flow - test onNewSearch() failure: Expect tierSupportActionTypes.TS_NODE_SEARCH_INVALID_TERMS action being passed When no cached suggestions are found', done => {
- const mStore = mockStore({});
- let mockNetwork = sinon.mock(networkCall);
- mockNetwork.expects('fetchRequest').never().withArgs(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword).returns(Promise.resolve(autoCompleteSearchBarTestConstants.networkError));
- let mockedNetworkFetchRequest = () => networkCall.fetchRequest(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword);
- wrapper.setProps({
- value: autoCompleteSearchBarTestConstants.nodeSearchKeyword,
- suggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits,
- cachedSuggestions: [],
- onNewSearch: (searchRequestObject, value) => {
- if (Object.keys(searchRequestObject).length === 0) {
- mStore.dispatch(getInvalidSearchInputEvent(autoCompleteSearchBarTestConstants.nodeSearchKeyword));
- } else {
- mStore.dispatch(querySelectedNodeElement(searchRequestObject, autoCompleteSearchBarTestConstants.nodeSearchKeyword, mockedNetworkFetchRequest));
- }
- }
-
- });
-
- function onInvalidSearchInputEvent(){
- return {
- type: tierSupportActionTypes.TS_NODE_SEARCH_INVALID_TERMS,
- data: {value: autoCompleteSearchBarTestConstants.nodeSearchKeyword, errorMsg: ERROR_INVALID_SEARCH_TERMS}
- };
- }
- wrapper.find('.auto-complete-search-button').simulate('click');
- mockNetwork.verify();
- mockNetwork.restore();
- setTimeout(() => {
- expect(mStore.getActions()[0]).to.deep.equal(onInvalidSearchInputEvent()), autoCompleteSearchBarTestConstants.mockRequestTimeOut;
- });
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- });
-
- it('Test flow - test onNewSearch() failure: Expect no matches found When no cached suggestions does not have the node searched for', done => {
- const mStore = mockStore({});
- let mockNetwork = sinon.mock(networkCall);
- mockNetwork.expects('fetchRequest').never().withArgs(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword).returns(Promise.resolve(autoCompleteSearchBarTestConstants.networkError));
- let mockedNetworkFetchRequest = () => networkCall.fetchRequest(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword);
- wrapper.setProps({
- value: autoCompleteSearchBarTestConstants.nodeSearchKeyword,
- suggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits,
- cachedSuggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType2.hits.hits,
- onNewSearch: (searchRequestObject, value) => {
- if (Object.keys(searchRequestObject).length === 0) {
- mStore.dispatch(getInvalidSearchInputEvent(autoCompleteSearchBarTestConstants.nodeSearchKeyword));
- } else {
- mStore.dispatch(querySelectedNodeElement(searchRequestObject, autoCompleteSearchBarTestConstants.nodeSearchKeyword, mockedNetworkFetchRequest));
- }
- }
-
- });
-
- function onInvalidSearchInputEvent(){
- return {
- type: tierSupportActionTypes.TS_NODE_SEARCH_INVALID_TERMS,
- data: {value: autoCompleteSearchBarTestConstants.nodeSearchKeyword, errorMsg: ERROR_INVALID_SEARCH_TERMS}
- };
- }
- wrapper.find('.auto-complete-search-button').simulate('click');
- mockNetwork.verify();
- mockNetwork.restore();
- setTimeout(() => {
- expect(mStore.getActions()[0]).to.deep.equal(onInvalidSearchInputEvent()), autoCompleteSearchBarTestConstants.mockRequestTimeOut;
- });
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- });
-
- it('Test flow - test onNewSearch() failure: Expect no node search When no matches are found in lookup search', done => {
- const mStore = mockStore({});
- let mockNetwork = sinon.mock(networkCall);
- mockNetwork.expects('fetchRequest').never().withArgs(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword).returns(Promise.resolve(autoCompleteSearchBarTestConstants.networkError));
- let mockedNetworkFetchRequest = () => networkCall.fetchRequest(TS_BACKEND_SEARCH_SELECTED_NODE_URL, POST, POST_HEADER, autoCompleteSearchBarTestConstants.nodeSearchKeyword);
- wrapper.setProps({
- value: autoCompleteSearchBarTestConstants.multipleNodeSearchKeyword,
- suggestions: [{_source:{ entityType:i18n(NO_MATCHES_FOUND),searchTags:''}}],
- cachedSuggestions: [{_source:{ entityType:i18n(NO_MATCHES_FOUND),searchTags:''}}],
- onNewSearch: (searchRequestObject, value) => {
- if (Object.keys(searchRequestObject).length === 0) {
- mStore.dispatch(getInvalidSearchInputEvent(autoCompleteSearchBarTestConstants.nodeSearchKeyword));
- } else {
- mStore.dispatch(querySelectedNodeElement(searchRequestObject, autoCompleteSearchBarTestConstants.nodeSearchKeyword, mockedNetworkFetchRequest));
- }
- }
-
- });
-
- function onInvalidSearchInputEvent(){
- return {
- type: tierSupportActionTypes.TS_NODE_SEARCH_INVALID_TERMS,
- data: {value: autoCompleteSearchBarTestConstants.nodeSearchKeyword, errorMsg: ERROR_INVALID_SEARCH_TERMS}
- };
-
- }
- wrapper.find('.react-autosuggest__input').simulate('focus');
- wrapper.find('.auto-complete-search-button').simulate('click');
- mockNetwork.verify();
- mockNetwork.restore();
- setTimeout(() => {
- expect(mStore.getActions()[0]).to.deep.equal(onInvalidSearchInputEvent()), autoCompleteSearchBarTestConstants.mockRequestTimeOut;
- });
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- });
-
- it('Expect the list to be populated when a the auto suggest input box is focused', function() {
- const mStore = mockStore({});
- wrapper.setProps({
- value: autoCompleteSearchBarTestConstants.nodeSearchKeywordWithOutEqualSign,
- suggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits,
- cachedSuggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits,
-
- });
- wrapper.find('.react-autosuggest__input').simulate('focus');
- expect(wrapper.find('Item').children()).to.have.length(6);
- });
-
- it('Expect small list to be populated when a the auto suggest input box is focused', function() {
- const mStore = mockStore({});
- wrapper.setProps({
- value: autoCompleteSearchBarTestConstants.nodeSearchKeyword,
- suggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType2.hits.hits,
- cachedSuggestions: autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType2.hits.hits,
-
- });
- wrapper.find('.react-autosuggest__input').simulate('focus');
- expect(wrapper.find('Item').children()).to.have.length(3);
- });
- });
-});
diff --git a/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarActions.test.js b/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarActions.test.js
deleted file mode 100644
index b1b89e0..0000000
--- a/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarActions.test.js
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-import {expect, deep} from "chai";
-import React from "react";
-import {Provider} from "react-redux";
-import sinon from "sinon";
-import configureStore from "redux-mock-store";
-import thunk from "redux-thunk";
-import {storeCreator} from "app/AppStore.js";
-import {
- autoCompleteSearchBarActionTypes,
- TS_BACKEND_SEARCH_SELECTED_NODE_URL,
- ERROR_INVALID_SEARCH_TERMS,
- TIER_SUPPORT_NETWORK_ERROR
-} from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBarConstants.js';
-import {
- searchResultsFound,
- clearSuggestionsTextField,
- onSuggestionsChange,
- onSuggestionsClearRequested,
- getInvalidSearchInputEvent,
- fetchRequestedValues,
- fetchSelectedNodeElement,
- queryRequestedValues
-} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarActions.js';
-import {tierSupportActionTypes, TSUI_SEARCH_URL} from "app/tierSupport/TierSupportConstants.js";
-import {getDynamicTSUISearchURL} from "app/tierSupport/TierSupportActions.js";
-import * as networkCall from "app/networking/NetworkCalls.js";
-import {POST,
- POST_HEADER,
- ERROR_RETRIEVING_DATA} from "app/networking/NetworkConstants.js";
-import autoCompleteSearchBarTestConstants from "./autoCompleteSearchBarTestConstants";
-
-const middlewares = [thunk]; // add your middlewares like `redux-thunk`
-const mockStore = configureStore(middlewares);
-
-
-describe('Core AutoCompleteSearchBar suite', function() {
-
- describe('AutoCompleteSearchBar - Actions test ', function() {
-
- function createState(currentScreen, tierSupport) {
- return {
- currentScreen: currentScreen,
- tierSupport: tierSupport
- };
- }
-
- it('Expect CLEAR_SUGGESTIONS_TEXT_FIELD action being passed When clearSuggestionsTextField is dispatched.', function(){
- const store = mockStore({});
- function clearSuggestionsTextFieldSuccess() {
- return {
- type: autoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS_TEXT_FIELD
- }
- }
-
- store.dispatch(clearSuggestionsTextField());
- expect(store.getActions()[0]).to.deep.equal(clearSuggestionsTextFieldSuccess());
- });
-
- it('Expect CLEAR_SUGGESTIONS action being passed When onSuggestionsClearRequested is dispatched.', function() {
- const store = mockStore({});
- function onSuggestionsClearRequestedSuccess() {
- return {
- type: autoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS
- }
- }
-
- store.dispatch(onSuggestionsClearRequested());
- expect(store.getActions()[0]).to.deep.equal(onSuggestionsClearRequestedSuccess());
-
- });
-
- it('Expect TS_NODE_SEARCH_INVALID_TERMS action being passed When getInvalidSearchInputEvent is dispatched.', function(){
- const store = mockStore({});
- const value = 'test';
-
- function onGetInvalidSearchInputEvent(){
- return{
- type: tierSupportActionTypes.TS_NODE_SEARCH_INVALID_TERMS,
- data: {value: value, errorMsg: ERROR_INVALID_SEARCH_TERMS}
- }
- }
-
- store.dispatch(getInvalidSearchInputEvent(value));
- expect(store.getActions()[0]).to.deep.equal(onGetInvalidSearchInputEvent());
-
- });
-
- });
-
- it('Expect SUGGESTION_CHANGED action being passed When onSuggestionsChangeSuccess is dispatched with tab key.', function() {
- const store = mockStore({});
- const value = 'test';
-
- function onSuggestionsChangeSuccess() {
- return {
- type: autoCompleteSearchBarActionTypes.SUGGESTION_CHANGED,
- data: value
- }
- }
-
- var event = {
- keyCode: 9
- };
-
- store.dispatch(onSuggestionsChange(event, value));
- expect(store.getActions()[0]).to.deep.equal(onSuggestionsChangeSuccess());
-
- });
-
- it('Expect SUGGESTION_CHANGED action being passed When onSuggestionsChange is dispatched with enter key.', function() {
- const store = mockStore({});
- const value = 'test';
-
- function onSuggestionsChangeSucessfull() {
- return {type: autoCompleteSearchBarActionTypes.SUGGESTION_CHANGED, data: value};
- }
-
- var event = {
- keyCode: 13
- };
-
- store.dispatch(onSuggestionsChange(event, value));
- expect(store.getActions()[0]).to.deep.equal(onSuggestionsChangeSucessfull());
- });
-
- it('Expect fetchRequest being called once and SUGGESTION_FOUND action being when passed fetchRequestedValues is dispatched, and a valid response is sent in mock', done => {
- const store = mockStore({});
- const value = 'test';
-
- let mockNetwork = sinon.mock(networkCall);
- mockNetwork.expects('fetchRequest').once().withArgs(TSUI_SEARCH_URL, POST, POST_HEADER, value).returns(Promise.resolve(autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1));
- store.dispatch(fetchRequestedValues(() => networkCall.fetchRequest(TSUI_SEARCH_URL, POST, POST_HEADER, value)));
- mockNetwork.verify();
- mockNetwork.restore();
-
- function onCreateSuggestionFoundEvent() {
- return {
- type: autoCompleteSearchBarActionTypes.SUGGESTION_FOUND,
- data: {suggestions : autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits }
- };
- }
-
- setTimeout(() => expect(store.getActions()[0]).to.deep.equal(onCreateSuggestionFoundEvent()), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
-
-
- });
-
- it('Expect fetchRequest being called once and SUGGESTION_NOT_FOUND action being when passed fetchRequestedValues is dispatched, and a valid response with no hits is sent in mock', done => {
- const store = mockStore({});
- const value = 'test';
-
- let mockNetwork = sinon.mock(networkCall);
- mockNetwork.expects('fetchRequest').once().withArgs(TSUI_SEARCH_URL, POST, POST_HEADER, value).returns(Promise.resolve(autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithOutHits));
- store.dispatch(fetchRequestedValues(() => networkCall.fetchRequest(TSUI_SEARCH_URL, POST, POST_HEADER, value)));
- mockNetwork.verify();
- mockNetwork.restore();
- function onCreateSuggestionNotFoundEvent() {
- return {
- type: autoCompleteSearchBarActionTypes.SUGGESTION_NOT_FOUND
- };
- }
-
- setTimeout(() => expect(store.getActions()[0]).to.deep.equal(onCreateSuggestionNotFoundEvent()), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- });
-
- it('Expect fetchRequest being called once and TIER_SUPPORT_NETWORK_ERROR action being when passed fetchRequestedValues is dispatched, and network error is sent in mock', done => {
- const store = mockStore({});
- const value = 'test';
-
- let mockNetwork = sinon.mock(networkCall);
- mockNetwork.expects('fetchRequest').once().withArgs(TSUI_SEARCH_URL, POST, POST_HEADER, value).returns(Promise.resolve(autoCompleteSearchBarTestConstants.networkError));
- store.dispatch(fetchRequestedValues(() => networkCall.fetchRequest(TSUI_SEARCH_URL, POST, POST_HEADER, value)));
- mockNetwork.verify();
- mockNetwork.restore();
-
- function onGetInvalidQueryEvent() {
- return {
- type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR,
- data: {value: value, errorMsg: ERROR_RETRIEVING_DATA}
- };
- }
-
- setTimeout(() => {
- expect(store.getActions()[0].type.toString()).to.equal(tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR.toString()), autoCompleteSearchBarTestConstants.mockRequestTimeOut
- });
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- });
-
- it('Expect fetchRequest being called once and SUGGESTION_FOUND action being when passed queryRequestedValues is dispatched, and network error is sent in mock', done => {
- const store = mockStore({});
- const value = 'test';
-
- let mockNetwork = sinon.mock(networkCall);
- mockNetwork.expects('fetchRequest').once().withArgs(TSUI_SEARCH_URL, POST, POST_HEADER, value).returns(Promise.resolve(autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1));
- store.dispatch(fetchRequestedValues(() => networkCall.fetchRequest(TSUI_SEARCH_URL, POST, POST_HEADER, value)));
- mockNetwork.verify();
- mockNetwork.restore();
-
- function onCreateSuggestionFoundEvent() {
- return {
- type: autoCompleteSearchBarActionTypes.SUGGESTION_FOUND,
- data: {suggestions : autoCompleteSearchBarTestConstants.validResponseJsonForRequestFromFetchWithHitsType1.hits.hits }
- };
- }
-
- setTimeout(() => expect(store.getActions()[0]).to.deep.equal(onCreateSuggestionFoundEvent()), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- });
-
- it('Expect TIER_SUPPORT_NETWORK_ERROR action being passed when clearSuggestionsTextField is dispatched with no mock, and network error is sent in mock', done => {
- const store = mockStore({});
- const value = 'test';
-
- store.dispatch(clearSuggestionsTextField());
-
- function onClearSuggestionsTextField() {
- return {type: autoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS_TEXT_FIELD};
- }
-
- setTimeout(() => expect(store.getActions()[0]).to.deep.equal(onClearSuggestionsTextField()), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- });
-
- it('Expect CLEAR_SUGGESTIONS action being passed when onSuggestionsClearRequested is dispatched with no mock, and network error is sent in mock', done => {
- const store = mockStore({});
- const value = 'test';
-
- store.dispatch(onSuggestionsClearRequested());
-
- function onSuggestionsClearRequestedExpected() {
- return{type: autoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS};
- }
-
- setTimeout(() => expect(store.getActions()[0]).to.deep.equal(onSuggestionsClearRequestedExpected()), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- setTimeout(() => done(), autoCompleteSearchBarTestConstants.mockRequestTimeOut);
- });
-});
diff --git a/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarReducer.test.js b/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarReducer.test.js
deleted file mode 100644
index a4c35e6..0000000
--- a/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarReducer.test.js
+++ /dev/null
@@ -1,136 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-import {expect} from 'chai';
-import React from 'react';
-import {Provider} from 'react-redux';
-import TestUtils from 'react-dom/test-utils';
-import {tierSupportActionTypes} from 'app/tierSupport/TierSupportConstants.js';
-import reducer from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarReducer.js';
-import {MESSAGE_LEVEL_WARNING, MESSAGE_LEVEL_DANGER} from 'utils/GlobalConstants.js';
-import {
- autoCompleteSearchBarActionTypes,
- NO_MATCHES_FOUND,
- ERROR_INVALID_SEARCH_TERMS} from 'generic-components/autoCompleteSearchBar/AutoCompleteSearchBarConstants.js';
-import {
- ERROR_RETRIEVING_DATA} from 'app/networking/NetworkConstants.js';
-
-describe('AutoCompleteSearchBar - Reducer test ', function() {
-
- const testSuggestionData = [
- {_source:{ entityType: 'vserver',searchTags:'testing'}},
- {_source:{ entityType: 'vserver',searchTags:'someTag'}},
- {_source:{ entityType: 'vserver',searchTags:'test2'}}];
-
- it('AutoCompleteSearchBar reducer - Suggestion not found', function() {
- const feedbackMsgText = '';
- const suggestions = [];
- const action = {type: autoCompleteSearchBarActionTypes.SUGGESTION_NOT_FOUND};
- const initialState = {
- suggestions: suggestions
- };
-
- const newState = reducer(initialState, action);
- expect(newState.suggestions).to.have.deep.property('[0]._source.entityType', 'No Matches Found');
- });
-
- it('AutoCompleteSearchBar reducer - Suggestion found', function() {
- const feedbackMsgText = '';
- const action =
- {
- type: autoCompleteSearchBarActionTypes.SUGGESTION_FOUND,
- data: {
- suggestions: testSuggestionData
- }
- };
- const initialState = {
- suggestions: []
- };
-
- const newState = reducer(initialState, action);
- expect(newState.suggestions).to.have.deep.property('[0]._source.searchTags', 'testing');
- expect(newState.suggestions).to.have.deep.property('[1]._source.searchTags', 'someTag');
- expect(newState.suggestions).to.have.deep.property('[2]._source.searchTags', 'test2');
- });
-
- it('AutoCompleteSearchBar reducer - Clear Suggestion field', function() {
- const feedbackMsgText = '';
- const action = {type: autoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS_TEXT_FIELD, value: 'test'};
- const initialState = {
- suggestions: testSuggestionData
- };
-
- const newState = reducer(initialState, action);
- expect(newState.suggestions).to.be.empty;
- expect(newState.value).to.equal('');
- });
-
- it('AutoCompleteSearchBar reducer - Clear Suggestions', function() {
- const feedbackMsgText = '';
- const action = {type: autoCompleteSearchBarActionTypes.CLEAR_SUGGESTIONS, value: 'test'};
- const initialState = {
- suggestions: testSuggestionData
- };
-
- const newState = reducer(initialState, action);
- expect(newState.suggestions).to.be.empty;
- });
-
- it('AutoCompleteSearchBar reducer - Suggestions changed', function() {
- const feedbackMsgText = '';
- const action = {type: autoCompleteSearchBarActionTypes.SUGGESTION_CHANGED, value: 'test'};
- const initialState = {
- suggestions: testSuggestionData
- };
-
- const newState = reducer(initialState, action);
- expect(newState.suggestions).to.have.deep.property('[0]._source.searchTags', 'testing');
- expect(newState.suggestions).to.have.deep.property('[1]._source.searchTags', 'someTag');
- expect(newState.suggestions).to.have.deep.property('[2]._source.searchTags', 'test2');
- });
-
- it('AutoCompleteSearchBar reducer - Network error', function() {
- const feedbackMsgText = '';
- const feedbackMsgSeverity = '';
- const action = {type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR, data: {value: 'test', errorMsg: ERROR_RETRIEVING_DATA}};
- const initialState = {
- suggestions: testSuggestionData
- };
-
- const newState = reducer(initialState, action);
- expect(newState.suggestions).to.be.empty;
- expect(newState.feedbackMsgText).to.equal(ERROR_RETRIEVING_DATA);
- expect(newState.feedbackMsgSeverity).to.equal(MESSAGE_LEVEL_DANGER);
- });
-
- it('AutoCompleteSearchBar reducer - TS_NODE_SEARCH_INVALID_TERMS', function(){
- const feedbackMsgText = ERROR_INVALID_SEARCH_TERMS;
- const action = {type: tierSupportActionTypes.TS_NODE_SEARCH_INVALID_TERMS, data: {value: 'test', errorMsg: ERROR_INVALID_SEARCH_TERMS}};
- const initialState = {
- suggestions: testSuggestionData
- };
- const newState = reducer(initialState, action);
- expect(newState.suggestions).to.be.empty;
- expect(newState.cachedSuggestions).to.be.empty;
- expect(newState.feedbackMsgText).to.equal(ERROR_INVALID_SEARCH_TERMS);
- expect(newState.feedbackMsgSeverity).to.equal(MESSAGE_LEVEL_WARNING);
- });
-
-});
diff --git a/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarTestConstants.js b/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarTestConstants.js
deleted file mode 100644
index 57f7af8..0000000
--- a/test/tierSupport/autoCompleteSearchBar/autoCompleteSearchBarTestConstants.js
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-const validResponseJsonForRequestFromFetchWithHitsType1 = {
- "took": 5,
- "timed_out": false,
- "_shards": {
- "total": 5,
- "successful": 5,
- "failed": 0
- },
- "hits": {
- "total": 9376,
- "max_score": 3.3899312,
- "hits": [
- {
- "_index": "entitysearchindex-localhost",
- "_type": "aaiEntities",
- "_id": "4785c7ec8ae11be12ca742248713346ea03a473ef65aa84bbea102c67fa5d",
- "_score": 3.3899312,
- "_source": {
- "entityType": "service-instance",
- "edgeTagQueryEntityFieldName": "service-instance.service-instance-id",
- "edgeTagQueryEntityFieldValue": "a162a2a2-ea7e-4e94-afc3-e9d064a3c2a1",
- "searchTagIDs": "0",
- "searchTags": "service-instance-id=a162a2a2-ea7e-4e94-afc3-e9d064a3c2a1"
- }
- },
- {
- "_index": "entitysearchindex-localhost",
- "_type": "aaiEntities",
- "_id": "8e9baedcbf1cb2f9439f6b8b5eeaf0b8fa364086c8ef5ee6edcf6f5da114",
- "_score": 3.1589103,
- "_source": {
- "entityType": "service-instance",
- "edgeTagQueryEntityFieldName": "service-instance.service-instance-id",
- "edgeTagQueryEntityFieldValue": "d1f3c3be-7a7f-42ea-a9ac-ca20af1588b8",
- "searchTagIDs": "0",
- "searchTags": "service-instance-id=d1f3c3be-7a7f-42ea-a9ac-ca20af1588b8"
- }
- },
- {
- "_index": "entitysearchindex-localhost",
- "_type": "aaiEntities",
- "_id": "dd4bdbf810f5c1bc7be7d91f241b0221d75617a45f574f2ed6207e9c8ceb9e",
- "_score": 3.147036,
- "_source": {
- "entityType": "service-instance",
- "edgeTagQueryEntityFieldName": "service-instance.service-instance-id",
- "edgeTagQueryEntityFieldValue": "6c27a7cb-d8e1-45a8-aa12-61a694201cca",
- "searchTagIDs": "0",
- "searchTags": "service-instance-id=6c27a7cb-d8e1-45a8-aa12-61a694201cca"
- }
- },
- {
- "_index": "entitysearchindex-localhost2",
- "_type": "aaiEntities",
- "_id": "4785c7ec8ae11be12ca742248713346ea03a473ef65aa84bbea102c67fa5d",
- "_score": 3.3899312,
- "_source": {
- "entityType": "service-instance",
- "edgeTagQueryEntityFieldName": "service-instance.service-instance-id",
- "edgeTagQueryEntityFieldValue": "a162a2a2-ea7e-4e94-afc3-e9d064a3c2a1",
- "searchTagIDs": "0",
- "searchTags": "service-instance-id=a162a2a2-ea7e-4e94-afc3-e9d064a3c2a1"
- }
- },
- {
- "_index": "entitysearchindex-localhost2",
- "_type": "aaiEntities",
- "_id": "8e9baedcbf1cb2f9439f6b8b5eeaf0b8fa364086c8ef5ee6edcf6f5da114",
- "_score": 3.1589103,
- "_source": {
- "entityType": "service-instance",
- "edgeTagQueryEntityFieldName": "service-instance.service-instance-id",
- "edgeTagQueryEntityFieldValue": "d1f3c3be-7a7f-42ea-a9ac-ca20af1588b8",
- "searchTagIDs": "0",
- "searchTags": "service-instance-id=d1f3c3be-7a7f-42ea-a9ac-ca20af1588b8"
- }
- },
- {
- "_index": "entitysearchindex-localhost2",
- "_type": "aaiEntities",
- "_id": "dd4bdbf810f5c1bc7be7d91f241b0221d75617a45f574f2ed6207e9c8ceb9e",
- "_score": 3.147036,
- "_source": {
- "entityType": "service-instance",
- "edgeTagQueryEntityFieldName": "service-instance.service-instance-id",
- "edgeTagQueryEntityFieldValue": "6c27a7cb-d8e1-45a8-aa12-61a694201cca",
- "searchTagIDs": "0",
- "searchTags": "service-instance-id=6c27a7cb-d8e1-45a8-aa12-61a694201cca"
- }
- }
- ]
- }
-};
-
-const validResponseJsonForRequestFromFetchWithHitsType2 = {
- "took": 5,
- "timed_out": false,
- "_shards": {
- "total": 5,
- "successful": 5,
- "failed": 0
- },
- "hits": {
- "total": 9376,
- "max_score": 3.3899312,
- "hits": [
- {
- "_index": "entitysearchindex-localhost",
- "_type": "aaiEntities",
- "_id": "4785c7ec8ae11be12ca742248713346ea03a473ef65aa84bbea102c67fa5d",
- "_score": 3.3899312,
- "_source": {
- "entityType": "service-instance",
- "edgeTagQueryEntityFieldName": "service-instance.service-instance-id",
- "entityPrimaryKeyValue": "a162a2a2-ea7e-4e94-afc3-e9d064a3c2a1",
- "searchTagIDs": "0",
- "searchTags": "hostname-id=a162a2a2-ea7e-4e94-afc3-e9d064a3c2a1"
- }
- },
- {
- "_index": "entitysearchindex-localhost",
- "_type": "aaiEntities",
- "_id": "8e9baedcbf1cb2f9439f6b8b5eeaf0b8fa364086c8ef5ee6edcf6f5da114",
- "_score": 3.1589103,
- "_source": {
- "entityType": "service-instance",
- "edgeTagQueryEntityFieldName": "service-instance.service-instance-id",
- "edgeTagQueryEntityFieldValue": "d1f3c3be-7a7f-42ea-a9ac-ca20af1588b8",
- "searchTagIDs": "0",
- "searchTags": "hostname-id=d1f3c3be-7a7f-42ea-a9ac-ca20af1588b8"
- }
- },
- {
- "_index": "entitysearchindex-localhost",
- "_type": "aaiEntities",
- "_id": "dd4bdbf810f5c1bc7be7d91f241b0221d75617a45f574f2ed6207e9c8ceb9e",
- "_score": 3.147036,
- "_source": {
- "entityType": "service-instance",
- "edgeTagQueryEntityFieldName": "service-instance.service-instance-id",
- "edgeTagQueryEntityFieldValue": "6c27a7cb-d8e1-45a8-aa12-61a694201cca",
- "searchTagIDs": "0",
- "searchTags": "hostname-id=6c27a7cb-d8e1-45a8-aa12-61a694201cca"
- }
- }
- ]
- }
-};
-
-const validResponseJsonForRequestFromFetchWithOutHits = {
- "took": 5,
- "timed_out": false,
- "_shards": {
- "total": 5,
- "successful": 5,
- "failed": 0
- },
- "hits": {
- "total": 0,
- "max_score": 3.3899312,
- "hits": []
- }
-};
-
-const networkError = {
- "error": "Network Error"
-};
-
-const validResponseJsonForNodeSearchFromFetchWithHits = {
- "graphMeta":{},
- "nodes" : [ {
- "id" : "service-instance.PRUCPEHOST0627002",
- "itemType" : "service-instance",
- "itemNameKey" : "service-instance.PRUCPEHOST0627002",
- "itemNameValue" : "PRUCPEHOST0627002",
- "itemProperties" : {
- "resource-version" : "1467233099",
- "service-instance-id" : "PRUCPEHOST0627002"
- },
- "nodeMeta" : {
- "className" : "selectedSearchedNodeClass",
- "nodeDebug" : null,
- "selfLinkResponseTimeInMs" : 131,
- "relationshipNode" : false,
- "searchTarget" : true,
- "enrichableNode" : false
- }
- } ]
-};
-
-const inValidResponseJsonForNodeSearchFromFetchWithHits = {
- "graphMeta":{},
- "nodes" : []
-};
-
-const nodeSearchKeyword = 'service-instance-id=a162a2a2-ea7e-4e94-afc3-e9d064a3c2a1';
-const nodeSearchKeywordWithOutEqualSign = 'a162a2a2-ea7e-4e94-afc3-e9d064a3c2a1';
-const multipleNodeSearchKeyword = 'service-instance-id=a162a2a2-ea7e-4e94-afc3-e9d064a3c2a1, service-instance-id=a162a2a2-ea7e-4e94-afc3-e9d064a3c2a1';
-const mockRequestTimeOut = 1;
-export default{
- validResponseJsonForRequestFromFetchWithHitsType1: validResponseJsonForRequestFromFetchWithHitsType1,
- validResponseJsonForRequestFromFetchWithHitsType2: validResponseJsonForRequestFromFetchWithHitsType2,
- validResponseJsonForRequestFromFetchWithOutHits: validResponseJsonForRequestFromFetchWithOutHits,
- networkError: networkError,
- validResponseJsonForNodeSearchFromFetchWithHits: validResponseJsonForNodeSearchFromFetchWithHits,
- inValidResponseJsonForNodeSearchFromFetchWithHits: inValidResponseJsonForNodeSearchFromFetchWithHits,
- nodeSearchKeyword: nodeSearchKeyword,
- nodeSearchKeywordWithOutEqualSign: nodeSearchKeywordWithOutEqualSign,
- multipleNodeSearchKeyword: multipleNodeSearchKeyword,
- mockRequestTimeOut: mockRequestTimeOut
-};
diff --git a/test/tierSupport/tierSupport.test.js b/test/tierSupport/tierSupport.test.js
deleted file mode 100644
index 533a6bf..0000000
--- a/test/tierSupport/tierSupport.test.js
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-import React from 'react';
-import {Provider} from 'react-redux';
-
-import TestUtilities from 'react-addons-test-utils';
-import { expect } from 'chai';
-
-import TierSupport from 'app/tierSupport/TierSupport.jsx';
-
-describe("Tier Support", function() {
-
- beforeEach(function() {
- this.component = TestUtilities.renderIntoDocument(<Provider store={store}><TierSupport /></Provider>);
- });
-
-});
diff --git a/test/utils/MockRest.js b/test/utils/MockRest.js
deleted file mode 100644
index b6840e2..0000000
--- a/test/utils/MockRest.js
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-const queue = {
- fetch: [],
- put: [],
- post: [],
- destroy: []
-};
-
-const initQueue = () => {
- queue['fetch'] = [];
- queue['put'] = [];
- queue['post'] = [];
- queue['destroy'] = [];
-};
-
-const handleOperation = (handler, options) => {
- if(typeof handler === 'function') {
- return Promise.resolve(handler(options));
- }
- else {
- return Promise.resolve(handler);
- }
-};
-
-export default {
-
- fetch(baseUrl, options) {
- const {fetch} = queue;
- if(!fetch.length) {
- throw new Error(`Fetch operation was called without proper handler. baseUrl: '${baseUrl}' options: '${options}'`);
- }
- return handleOperation(fetch.shift(), {options, baseUrl});
- },
-
- put(baseUrl, data, options) {
- const {put} = queue;
- if(!put.length) {
- throw new Error(`put operation was called without proper handler. baseUrl: '${baseUrl}' options: '${options}'`);
- }
- return handleOperation(put.shift(), {data, options, baseUrl});
- },
-
- post(baseUrl, data, options) {
- const {post} = queue;
- if(!post.length) {
- throw new Error(`post operation was called without proper handler. baseUrl: '${baseUrl}' options: '${options}'`);
- }
- return handleOperation(post.shift(), {data, options, baseUrl});
- },
-
- destroy(baseUrl, options) {
- const {destroy} = queue;
- if(!destroy.length) {
- throw new Error(`Destroy operation was called without proper handler. baseUrl: '${baseUrl}' options: '${options}'`);
- }
- return handleOperation(destroy.shift(), {options, baseUrl});
- },
-
- addHandler(operation, handler) {
- queue[operation].push(handler);
- },
-
- resetQueue() {
- initQueue();
- }
-};
diff --git a/test/vnfSearch/vnfSearchVisualizations/vnfSearchVisualizations.test.js b/test/vnfSearch/vnfSearchVisualizations/vnfSearchVisualizations.test.js
deleted file mode 100644
index 0b893a9..0000000
--- a/test/vnfSearch/vnfSearchVisualizations/vnfSearchVisualizations.test.js
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-import React from 'react';
-import TestUtils from 'react-dom/test-utils';
-import {storeCreator} from 'app/AppStore.js';
-import {Provider} from 'react-redux';
-import { expect } from 'chai';
-import VnfSearchOrchStatusVisualizations from 'app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx';
-import VnfSearchProvStatusVisualizations from 'app/vnfSearch/VnfSearchProvStatusVisualization.jsx';
-import VnfSearchTotalCountVisualization from 'app/vnfSearch/VnfSearchTotalCountVisualization.jsx';
-import {
- CHART_PROV_STATUS,
- CHART_ORCH_STATUS,
- TOTAL_VNF_COUNT} from 'app/vnfSearch/VnfSearchConstants.js';
-
-describe('VNF Visualizations Structure Tests', function () {
-
- function createState(processedOrchStatusCountChartData,
- processedProvStatusCountChartData) {
- return {
- vnfSearch: {
- auditVisualizationsData: {
- processedOrchStatusCountChartData: processedOrchStatusCountChartData,
- processedProvStatusCountChartData: processedProvStatusCountChartData
- }
- }
- };
- }
-
- it('VNF: Visualization layout VNF Orch Status, no data', function () {
- const store = storeCreator(createState(
- CHART_ORCH_STATUS.clearingEmptyData,
- CHART_PROV_STATUS.clearingEmptyData
- ));
- this.component = TestUtils.renderIntoDocument(
- <Provider store={store}>
- <VnfSearchOrchStatusVisualizations />
- </Provider>
- );
- let visualizationContainer = TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'visualizations');
- expect(visualizationContainer).to.exist; // there is always a visualizations container
- expect(visualizationContainer[0].className).to.contain('hidden'); // make sure visualizations is hidden
- });
-
- it('VNF: Visualization layout VNF Prov Status, no data', function () {
- const store = storeCreator(createState(
- CHART_ORCH_STATUS.clearingEmptyData,
- CHART_PROV_STATUS.clearingEmptyData
- ));
- this.component = TestUtils.renderIntoDocument(
- <Provider store={store}>
- <VnfSearchProvStatusVisualizations />
- </Provider>
- );
- let visualizationContainer = TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'visualizations');
- expect(visualizationContainer).to.exist; // there is always a visualizations container
- expect(visualizationContainer[0].className).to.contain('hidden'); // make sure visualizations is hidden
- });
-
-
- it('VNF: Visualization layout Total VNF, no data', function () {
- const store = storeCreator(createState(
- TOTAL_VNF_COUNT.clearingEmptyValue
- ));
- this.component = TestUtils.renderIntoDocument(
- <Provider store={store}>
- <VnfSearchTotalCountVisualization />
- </Provider>
- );
- let visualizationContainer = TestUtils.scryRenderedDOMComponentsWithClass(this.component, 'visualizations');
- expect(visualizationContainer).to.exist; // there is always a visualizations container
- expect(visualizationContainer[0].className).to.contain('hidden'); // make sure visualizations is hidden
- });
-});
diff --git a/test/vnfSearch/vnfSearchVisualizations/vnfSearchVisualizationsReducer.test.js b/test/vnfSearch/vnfSearchVisualizations/vnfSearchVisualizationsReducer.test.js
deleted file mode 100644
index 81ed2bf..0000000
--- a/test/vnfSearch/vnfSearchVisualizations/vnfSearchVisualizationsReducer.test.js
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * org.onap.aai
- * ================================================================================
- * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2018 Amdocs
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-import React from 'react';
-import { expect } from 'chai';
-import reducer from 'app/vnfSearch/VnfSearchReducer.js';
-import {
- CHART_ORCH_STATUS,
- CHART_PROV_STATUS, vnfSearchVisualizationsActionTypes} from 'app/vnfSearch/VnfSearchConstants.js';
-
-
-
-describe('VNF: Audit Visualizations Reducers test suite', function() {
- const initialState = {
- processedProvStatusCountChartData: CHART_PROV_STATUS.clearingEmptyData,
- processedOrchStatusCountChartData: CHART_ORCH_STATUS.clearingEmptyData
- };
- const initStateWithData = {
- processedProvStatusCountChartData: [
- {
- values: [
- {
- x: 'complex',
- y: 60
- }
- ]
- }
- ],
- processedOrchStatusCountChartData: [
- {
- values: [
- {
- x: 'prov-status',
- y: 60
- }
- ]
- }
- ]
- };
-
-
-
- it('VNF: COUNT_BY_ORCH_STATUS_RECEIVED event', function() {
- const chartData = [
- {
- 'values': [
- { 'x': 'physical-location-id', 'y': 22},
- { 'x': 'prov-status', 'y': 14},
- { 'x': 'status-type-3', 'y': 24}
- ]
- }
- ];
-
- const action = {
- type: vnfSearchVisualizationsActionTypes.COUNT_BY_ORCH_STATUS_RECEIVED,
- data: {
- orchStatusCountChartData: {
- chartData: chartData,
- }
- }
- };
-
- const newState = reducer(initialState, action);
- expect(newState.processedOrchStatusCountChartData[0].values.length).to.equal(3);
- expect(newState.processedOrchStatusCountChartData[0].values[0]['x']).to.equal('physical-location-id');
- expect(newState.processedOrchStatusCountChartData[0].values[1]['x']).to.equal('prov-status');
- expect(newState.processedOrchStatusCountChartData[0].values[2]['x']).to.equal('status-type-3');
- expect(newState.processedOrchStatusCountChartData[0].values[0]['y']).to.equal(22);
- expect(newState.processedOrchStatusCountChartData[0].values[1]['y']).to.equal(14);
- expect(newState.processedOrchStatusCountChartData[0].values[2]['y']).to.equal(24);
- });
-
- it('VNF: COUNT_BY_PROV_STATUS_RECEIVED event', function() {
- const chartData = [
- {
- 'values': [
- { 'x': 'physical-location-id', 'y': 22},
- { 'x': 'prov-status', 'y': 14},
- { 'x': 'status-type-3', 'y': 24}
- ]
- }
- ];
-
- const action = {
- type: vnfSearchVisualizationsActionTypes.COUNT_BY_PROV_STATUS_RECEIVED,
- data: {
- provStatusCountChartData: {
- chartData: chartData,
- }
- }
- };
-
- const newState = reducer(initialState, action);
- expect(newState.processedProvStatusCountChartData[0].values.length).to.equal(3);
- expect(newState.processedProvStatusCountChartData[0].values[0]['x']).to.equal('physical-location-id');
- expect(newState.processedProvStatusCountChartData[0].values[1]['x']).to.equal('prov-status');
- expect(newState.processedProvStatusCountChartData[0].values[2]['x']).to.equal('status-type-3');
- expect(newState.processedProvStatusCountChartData[0].values[0]['y']).to.equal(22);
- expect(newState.processedProvStatusCountChartData[0].values[1]['y']).to.equal(14);
- expect(newState.processedProvStatusCountChartData[0].values[2]['y']).to.equal(24);
- });
-
-
- it('VNF: Total VNF event', function() {
-
-
- const action = {
- type: vnfSearchVisualizationsActionTypes.TOTAL_VNF_COUNT_RECEIVED,
- data: {count: 10}
- };
-
- const newState = reducer(initialState, action);
- expect(newState.count).to.equal(10);
-
- });
-
-
- it('VNF: NETWORK_ERROR event', function() {
- const action = {
- type: vnfSearchVisualizationsActionTypes.VNF_SEARCH_NETWORK_ERROR
- }
- const newState = reducer(initStateWithData, action);
- expect(newState.processedProvStatusCountChartData).to.deep.equal(CHART_PROV_STATUS.clearingEmptyData);
- expect(newState.processedOrchStatusCountChartData).to.deep.equal(CHART_ORCH_STATUS.clearingEmptyData);
- });
-
-});