summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--package.json83
-rw-r--r--src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx2
-rw-r--r--src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.test.js141
-rw-r--r--src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.test.js248
-rw-r--r--src/app/vnfSearch/VnfSearch.jsx2
-rw-r--r--src/app/vnfSearch/VnfSearch.test.js49
-rw-r--r--src/app/vnfSearch/VnfSearchActions.js3
-rw-r--r--src/app/vnfSearch/VnfSearchActions.test.js215
-rw-r--r--src/app/vnfSearch/VnfSearchNfRoleVisualization.jsx2
-rw-r--r--src/app/vnfSearch/VnfSearchNfRoleVisualization.test.js154
-rw-r--r--src/app/vnfSearch/VnfSearchNfTypeVisualization.jsx2
-rw-r--r--src/app/vnfSearch/VnfSearchNfTypeVisualization.test.js154
-rw-r--r--src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx2
-rw-r--r--src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js154
-rw-r--r--src/app/vnfSearch/VnfSearchProvStatusVisualization.jsx2
-rw-r--r--src/app/vnfSearch/VnfSearchProvStatusVisualization.test.js154
-rw-r--r--src/app/vnfSearch/VnfSearchReducer.test.js438
-rw-r--r--src/app/vnfSearch/VnfSearchTotalCountVisualization.jsx2
-rw-r--r--src/app/vnfSearch/VnfSearchTotalCountVisualization.test.js131
-rw-r--r--src/utils/DateTimeChartUtil.test.js92
-rw-r--r--src/utils/SpinnerContainer.jsx1
-rw-r--r--src/utils/SpinnerContainer.test.js35
-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
39 files changed, 2027 insertions, 2144 deletions
diff --git a/.gitignore b/.gitignore
index 3e1100f..d5fd50c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,6 @@
.idea
-
+coverage
dist
node
target
diff --git a/package.json b/package.json
index ddbc889..55e7652 100644
--- a/package.json
+++ b/package.json
@@ -3,16 +3,14 @@
"version": "1.0.0",
"description": "",
"main": "bundle.js",
- "directories": {
- "test": "test"
- },
"publishConfig": {
"registry": "http://10.247.57.144:8081/repository/npm-aee/"
},
"scripts": {
"start": "gulp",
"build": "gulp build",
- "test": "karma start"
+ "test": "jest",
+ "testReport": "jest --coverage"
},
"author": "",
"license": "SEE LICENSE IN LICENSE",
@@ -30,19 +28,20 @@
"moment": "^2.13.0",
"moment-timezone": "^0.5.5",
"node-fetch": "^1.5.3",
- "react": "^15.4.0",
+ "react": "^15.6.1",
"react-autosuggest": "^6.0.4",
- "react-bootstrap": "^0.30.0-rc.1",
- "react-datepicker": "^0.53.0",
- "react-dom": "^15.1.0",
+ "react-bootstrap": "^0.31.2",
+ "react-datepicker": "^0.55.0",
+ "react-dom": "^15.6.1",
"react-fontawesome": "^0.3.3",
"react-grid-layout": "^0.14.4",
"react-highlight-words": "^0.4.1",
"react-redux": "^4.4.1",
"react-router-dom": "^4.1.1",
- "react-select": "^1.0.0-beta13",
+ "react-select": "^1.2.1",
"react-spinners": "^0.2.5",
"react-split-pane": "^0.1.51",
+ "recharts": "^0.20.5",
"redux": "^3.3.1",
"redux-form": "^6.2.1",
"redux-thunk": "^2.1.0",
@@ -52,23 +51,25 @@
"vertical-filter-bar": "1.0.4"
},
"devDependencies": {
- "babel-core": "^6.9.1",
- "babel-eslint": "^6.0.2",
+ "babel-core": "^6.25.0",
+ "babel-eslint": "^6.0.4",
+ "babel-jest": "^22.4.1",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.9.0",
"babel-preset-react": "^6.5.0",
"babel-preset-stage-0": "^6.5.0",
- "chai": "^3.5.0",
"copy-webpack-plugin": "^4.0.1",
"crypto-js": "^3.1.9-1",
"css-loader": "^0.23.1",
- "enzyme": "^2.5.1",
+ "enzyme": "^3.3.0",
+ "enzyme-adapter-react-15": "^1.0.5",
"eslint": "^3.1.1",
"eslint-loader": "^1.3.0",
"eslint-plugin-import": "^0.8.1",
"eslint-plugin-react": "^3.14.0",
"expect": "^1.20.1",
"express": "^4.13.3",
+ "fetch-mock": "^5.13.1",
"file-loader": "^0.8.5",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.1",
@@ -82,44 +83,54 @@
"isparta-loader": "^2.0.0",
"istanbul": "^1.0.0-alpha.2",
"istanbul-instrumenter-loader": "^0.2.0",
- "jasmine-core": "^2.8.0",
+ "jest": "^22.4.3",
+ "jest-enzyme": "^6.0.0",
+ "jest-fetch-mock": "^1.5.0",
"json-loader": "^0.5.4",
"jsx-loader": "^0.13.2",
- "karma": "^0.13.22",
- "karma-babel-preprocessor": "^6.0.1",
- "karma-chai": "^0.1.0",
- "karma-chrome-launcher": "^1.0.1",
- "karma-cli": "^1.0.0",
- "karma-coverage": "^1.0.0",
- "karma-firefox-launcher": "^1.0.0",
- "karma-jasmine": "^1.1.0",
- "karma-jasmine-html-reporter": "^0.2.2",
- "karma-mocha": "^1.0.1",
- "karma-sinon-chai": "^1.2.3",
- "karma-sourcemap-loader": "^0.3.7",
- "karma-verbose-reporter": "0.0.5",
- "karma-webpack": "^1.7.0",
- "mocha": "^2.4.5",
- "mock-require": "^1.2.1",
"nock": "^8.0.0",
"node-sass": "^3.8.0",
"node-watch": "^0.3.5",
"prompt": "^0.2.14",
"react-addons-test-utils": "^15.1.0",
- "react-bootstrap": "^0.30.0-rc.1",
"react-hot-loader": "^3.0.0-beta.6",
- "react-split-pane": "^0.1.51",
- "recharts": "^0.20.5",
- "redux-mock-store": "^1.1.2",
+ "react-test-renderer": "^15.6.1",
+ "redux-mock-store": "^1.4.0",
"sass-loader": "^3.1.2",
- "sinon": "^2.0.0-pre",
- "sinon-chai": "^2.14.0",
"source-map-loader": "^0.1.5",
"style-loader": "^0.13.1",
"url-loader": "^0.5.7",
"webpack": "^1.13.1",
"webpack-dev-server": "^1.14.1"
},
+ "jest": {
+ "verbose": true,
+ "setupTestFrameworkScriptFile": "./test/setupTests.js",
+ "automock": false,
+ "moduleNameMapper": {
+ "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/test/fileMock.js",
+ "\\.(css|scss)$": "<rootDir>/test/styleMock.js"
+ },
+ "moduleFileExtensions": [
+ "js",
+ "jsx"
+ ],
+ "moduleDirectories": [
+ "node_modules",
+ "src",
+ "utils"
+ ],
+ "collectCoverage": true,
+ "collectCoverageFrom": [
+ "**/*.{js,jsx}",
+ "!**/node_modules/**",
+ "!**/test/**",
+ "!**/resources/**",
+ "!**/dist/**",
+ "!**/scripts/**",
+ "!**/tools/**"
+ ]
+ },
"engines": {
"node": ">=5.1",
"npm": ">=3.3"
diff --git a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx
index 88536e6..5750fd9 100644
--- a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx
+++ b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.jsx
@@ -39,7 +39,7 @@ let mapStateToProps = ({tierSupport: {selectedNodeDetails}}) => {
};
};
-class SelectedNodeDetails extends Component {
+export class SelectedNodeDetails extends Component {
static propTypes = {
nodeData: React.PropTypes.object,
nodeType: React.PropTypes.string,
diff --git a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.test.js b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.test.js
new file mode 100644
index 0000000..60f5530
--- /dev/null
+++ b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetails.test.js
@@ -0,0 +1,141 @@
+import React from 'react';
+import { shallow, mount } from 'enzyme';
+import {Provider} from 'react-redux'
+import configureStore from 'redux-mock-store';
+import Table from 'react-bootstrap/lib/Table';
+
+import ConnectedSelectedNodeDetails, { SelectedNodeDetails } from './SelectedNodeDetails.jsx';
+import { SELECTED_NODE_TABLE_COLUMN_NAMES } from './SelectedNodeDetailsConstants.js';
+import LaunchInContext from '../launchExternalResource/LaunchExternalResource.jsx';
+
+describe('SelectedNodeDetails - Shallow render of component', () => {
+ let wrapper;
+ const nodeTypeProp = 'VNF';
+ const uidProp = 'SomeValidUIDName';
+ const nodeDataProp = {
+ 'interface-role': 'MPLS',
+ 'in-maint': 'false',
+ 'interface-type': 'WAN',
+ 'port-description': 'MPLS port on 10_NSG16_location4',
+ 'resource-version': '123456789',
+ 'interface-name': '10_port1_location4',
+ 'uri': 'network/pnfs/pnf/10_NSG14_location4/p-interfaces/p-interface/10_port1_location4'
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <SelectedNodeDetails
+ nodeType={nodeTypeProp}
+ nodeData={nodeDataProp}
+ uid={uidProp}
+ />);
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ });
+
+ it('Verify node type is displayed as a header', () => {
+ expect(wrapper.contains(<h2>{nodeTypeProp}</h2>)).toBe(true);
+ expect(wrapper.find('h2')).toHaveLength(1);
+ });
+
+ it('Verify uid is displayed', () => {
+ expect(wrapper.contains(<span>{uidProp} <LaunchInContext/></span>)).toBe(true);
+ });
+
+ it('Verify node data table is displayed', () => {
+ // verify table has a row for each node data prop plus one row for the column headers
+ expect(wrapper.find(Table)).toHaveLength(1);
+ expect(wrapper.find(Table).props().bsClass).toEqual('ts-selected-node-table');
+ expect(wrapper.find(Table).children()).toHaveLength(2); // thead and tbody
+
+ // validate the table header content
+ expect(wrapper.find('thead')).toHaveLength(1);
+ let cellClassName;
+ for (let index = 1; index <= SELECTED_NODE_TABLE_COLUMN_NAMES.length; index++) {
+ cellClassName = (index % 2 ? 'left-column-cell' : 'right-column-cell');
+ expect(wrapper.contains(
+ <th className={cellClassName} key={index}>{SELECTED_NODE_TABLE_COLUMN_NAMES[index-1]}</th>
+ )).toBe(true);
+ }
+
+ // validate the table body content
+ expect(wrapper.find('tbody')).toHaveLength(1);
+ expect(wrapper.find('tbody').children()).toHaveLength(7); // 1 row for each of the 7 properties
+ for (let prop in nodeDataProp) {
+ expect(wrapper.contains(
+ <td className='left-column-cell'>{prop}</td>
+ )).toBe(true);
+ expect(wrapper.contains(
+ <td className='right-column-cell'>{nodeDataProp[prop]}</td>
+ )).toBe(true);
+ }
+ });
+})
+
+describe('SelectedNodeDetails - Shallow render of component with no node data', () => {
+ let wrapper;
+ const nodeTypeProp = 'VNF';
+ const uidProp = 'SomeValidUIDName';
+ const nodeDataProp = {};
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <SelectedNodeDetails
+ nodeType={nodeTypeProp}
+ nodeData={nodeDataProp}
+ uid={uidProp}
+ />);
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ });
+
+ it('Verify node data table is hidden', () => {
+ // verify table is hidden
+ expect(wrapper.find(Table)).toHaveLength(1);
+ expect(wrapper.find(Table).props().bsClass).toEqual('hidden');
+ });
+})
+
+describe('SelectedNodeDetails - Render React Component (wrapped in <Provider>)', () => {
+ const initialState = {
+ tierSupport: {
+ launchExternalResourceReducer: {
+ externalResourcePayload: {}
+ },
+ selectedNodeDetails: {
+ nodeType: 'VNF',
+ uid: 'AAI/CLYMR/000509/SD_WAN',
+ nodeData: {
+ 'interface-role': 'MPLS',
+ 'in-maint': 'false',
+ 'interface-type': 'WAN',
+ 'port-description': 'MPLS port on 10_NSG16_location4',
+ 'resource-version': '123456789',
+ 'interface-name': '10_port1_location4',
+ 'uri': 'network/pnfs/pnf/10_NSG14_location4/p-interfaces/p-interface/10_port1_location4'
+ }
+ }
+ }
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = mount(<Provider store={store}><ConnectedSelectedNodeDetails /></Provider>);
+ })
+
+ it('Render the connected component', () => {
+ expect(wrapper.find(ConnectedSelectedNodeDetails).length).toEqual(1);
+ });
+
+ it('Validate props from store', () => {
+ expect(wrapper.find(SelectedNodeDetails).props().uid).toEqual(initialState.tierSupport.selectedNodeDetails.uid);
+ expect(wrapper.find(SelectedNodeDetails).props().nodeType).toEqual(initialState.tierSupport.selectedNodeDetails.nodeType);
+ expect(wrapper.find(SelectedNodeDetails).props().nodeData).toEqual(initialState.tierSupport.selectedNodeDetails.nodeData);
+ });
+})
diff --git a/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.test.js b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.test.js
new file mode 100644
index 0000000..2544a80
--- /dev/null
+++ b/src/app/tierSupport/selectedNodeDetails/SelectedNodeDetailsReducer.test.js
@@ -0,0 +1,248 @@
+import SelectedNodeDetailsReducer from './SelectedNodeDetailsReducer.js';
+import {tierSupportActionTypes} from 'app/tierSupport/TierSupportConstants.js';
+import {
+ globalAutoCompleteSearchBarActionTypes
+} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js';
+
+describe('SelectedNodeDetails - Reducer Tests', () => {
+ it('Action Type: TS_NODE_SEARCH_RESULTS', () => {
+ const action = {
+ type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS,
+ data: {
+ nodes: [
+ {
+ 'id': 'AAI/CLYMR/000509/SD_WAN',
+ 'itemType': 'service-instance',
+ 'itemNameKey': 'service-instance.AAI/SPRKY/000509/SD_WAN',
+ 'itemNameValue': 'AAI/SPRKY/000509/SD_WAN',
+ 'itemProperties': {
+ 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN',
+ 'resource-version':'1508078039815'
+ },
+ 'itemIntegrity' : {
+ 'entityId' : 'AEEhny_vnf1_under_fw-si1',
+ 'entityType' : 'vnf',
+ 'entityLink' : 'cloud-infrastr084-1377-4f49-9c72-f0_location2',
+ 'initialTimestamp' :'2017-11-13T16:58:01Z',
+ 'latestValidationTimestamp':'2017-11-13T16:58:01Z',
+ 'resourceVersion':'1510592264096',
+ 'violations': []
+ },
+ 'nodeMeta': {
+ 'className': 'selectedSearchedNodeClass',
+ 'nodeDebug': null,
+ 'selfLinkResponseTimeInMs': 628,
+ 'relationshipNode': false,
+ 'searchTarget': true,
+ 'enrichableNode': false,
+ 'nodeValidated': true,
+ 'nodeIssue': false,
+ 'maxAltitude': 4,
+ 'nodeType': 'serviceInstance',
+ 'nodeLabel1':'service-instance',
+ 'nodeLabel2':'AAI/SPRKY/000509/SD_WAN'
+ },
+ 'rootNode' : false
+ }
+ ]
+ }
+ };
+ let state = {
+ nodeType: '',
+ uid: '',
+ nodeData: {}
+ };
+ state = SelectedNodeDetailsReducer(state, action);
+ expect(state).toEqual({
+ nodeType: action['data']['nodes'][0]['itemType'],
+ uid: action['data']['nodes'][0]['itemNameValue'],
+ nodeData: action['data']['nodes'][0]['itemProperties']
+ });
+ });
+
+ it('Action Type: TS_NODE_SEARCH_RESULTS - searchTarget === false', () => {
+ const action = {
+ type: tierSupportActionTypes.TS_NODE_SEARCH_RESULTS,
+ data: {
+ nodes: [
+ {
+ 'id': 'AAI/CLYMR/000509/SD_WAN',
+ 'itemType': 'service-instance',
+ 'itemNameKey': 'service-instance.AAI/SPRKY/000509/SD_WAN',
+ 'itemNameValue': 'AAI/SPRKY/000509/SD_WAN',
+ 'itemProperties': {
+ 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN',
+ 'resource-version':'1508078039815'
+ },
+ 'itemIntegrity' : {
+ 'entityId' : 'AEEhny_vnf1_under_fw-si1',
+ 'entityType' : 'vnf',
+ 'entityLink' : 'cloud-infrastr084-1377-4f49-9c72-f0_location2',
+ 'initialTimestamp' :'2017-11-13T16:58:01Z',
+ 'latestValidationTimestamp':'2017-11-13T16:58:01Z',
+ 'resourceVersion':'1510592264096',
+ 'violations': []
+ },
+ 'nodeMeta': {
+ 'className': 'selectedSearchedNodeClass',
+ 'nodeDebug': null,
+ 'selfLinkResponseTimeInMs': 628,
+ 'relationshipNode': false,
+ 'searchTarget': false,
+ 'enrichableNode': false,
+ 'nodeValidated': true,
+ 'nodeIssue': false,
+ 'maxAltitude': 4,
+ 'nodeType': 'serviceInstance',
+ 'nodeLabel1':'service-instance',
+ 'nodeLabel2':'AAI/SPRKY/000509/SD_WAN'
+ },
+ 'rootNode' : false
+ }
+ ]
+ }
+ };
+ let state = {
+ nodeType: 'Complex',
+ uid: 'ABC',
+ nodeData: {
+ 'service-instance-id': 'blah/blah/blah',
+ 'resource-version':'123456'
+ }
+ };
+ state = SelectedNodeDetailsReducer(state, action);
+ expect(state).toEqual({
+ nodeType: '',
+ uid: '',
+ nodeData: {}
+ });
+ });
+
+ it('Action Type: TS_GRAPH_NODE_SELECTED', () => {
+ const action = {
+ type: tierSupportActionTypes.TS_GRAPH_NODE_SELECTED,
+ data: {
+ itemProperties: {
+ 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN',
+ 'resource-version':'1508078039815'
+ },
+ itemType: 'Complex',
+ itemNameValue: '123456'
+ }
+ };
+ let state = {
+ nodeType: '',
+ uid: '',
+ nodeData: {}
+ };
+ state = SelectedNodeDetailsReducer(state, action);
+ expect(state).toEqual({
+ nodeType: action['data']['itemType'],
+ uid: action['data']['itemNameValue'],
+ nodeData: action['data']['itemProperties']
+ });
+ });
+
+ it('Action Type: TIER_SUPPORT_NETWORK_ERROR', () => {
+ const action = {
+ type: tierSupportActionTypes.TIER_SUPPORT_NETWORK_ERROR,
+ };
+ let state = {
+ nodeType: 'Complex',
+ uid: '12345',
+ nodeData: {
+ 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN',
+ 'resource-version':'1508078039815'
+ }
+ };
+ state = SelectedNodeDetailsReducer(state, action);
+ expect(state).toEqual({
+ nodeType: '',
+ uid: '',
+ nodeData: {}
+ });
+ });
+
+ it('Action Type: TIER_SUPPORT_CLEAR_DATA', () => {
+ const action = {
+ type: tierSupportActionTypes.TIER_SUPPORT_CLEAR_DATA,
+ };
+ let state = {
+ nodeType: 'Complex',
+ uid: '12345',
+ nodeData: {
+ 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN',
+ 'resource-version':'1508078039815'
+ }
+ };
+ state = SelectedNodeDetailsReducer(state, action);
+ expect(state).toEqual({
+ nodeType: '',
+ uid: '',
+ nodeData: {}
+ });
+ });
+
+ it('Action Type: TS_NODE_SEARCH_NO_RESULTS', () => {
+ const action = {
+ type: tierSupportActionTypes.TS_NODE_SEARCH_NO_RESULTS,
+ };
+ let state = {
+ nodeType: 'Complex',
+ uid: '12345',
+ nodeData: {
+ 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN',
+ 'resource-version':'1508078039815'
+ }
+ };
+ state = SelectedNodeDetailsReducer(state, action);
+ expect(state).toEqual({
+ nodeType: '',
+ uid: '',
+ nodeData: {}
+ });
+ });
+
+ it('Action Type: SEARCH_WARNING_EVENT', () => {
+ const action = {
+ type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT,
+ };
+ let state = {
+ nodeType: 'Complex',
+ uid: '12345',
+ nodeData: {
+ 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN',
+ 'resource-version':'1508078039815'
+ }
+ };
+ state = SelectedNodeDetailsReducer(state, action);
+ expect(state).toEqual({
+ nodeType: '',
+ uid: '',
+ nodeData: {}
+ });
+ });
+
+ it('Invalid Action Type', () => {
+ const action = {
+ type: 'Nonexistent Action Type',
+ };
+ let state = {
+ nodeType: 'Complex',
+ uid: '12345',
+ nodeData: {
+ 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN',
+ 'resource-version':'1508078039815'
+ }
+ };
+ state = SelectedNodeDetailsReducer(state, action);
+ expect(state).toEqual({
+ nodeType: 'Complex',
+ uid: '12345',
+ nodeData: {
+ 'service-instance-id': 'AAI/SPRKY/000509/SD_WAN',
+ 'resource-version':'1508078039815'
+ }
+ });
+ });
+})
diff --git a/src/app/vnfSearch/VnfSearch.jsx b/src/app/vnfSearch/VnfSearch.jsx
index dbcc73d..a409ce2 100644
--- a/src/app/vnfSearch/VnfSearch.jsx
+++ b/src/app/vnfSearch/VnfSearch.jsx
@@ -157,7 +157,7 @@ let mapActionToProps = (dispatch) => {
};
};
-class vnfSearch extends Component {
+export class vnfSearch extends Component {
static propTypes = {
feedbackMsgText: React.PropTypes.string,
feedbackSeverity: React.PropTypes.string,
diff --git a/src/app/vnfSearch/VnfSearch.test.js b/src/app/vnfSearch/VnfSearch.test.js
new file mode 100644
index 0000000..c6c63fc
--- /dev/null
+++ b/src/app/vnfSearch/VnfSearch.test.js
@@ -0,0 +1,49 @@
+import React from 'react';
+import { shallow, mount } from 'enzyme';
+import {Provider} from 'react-redux'
+import configureStore from 'redux-mock-store';
+
+import ConnectedVnfSearch, { vnfSearch } from './VnfSearch.jsx';
+
+describe('VnfSearch - Shallow render of component', () => {
+ let wrapper;
+ const vnfFilters = {};
+ const vnfVisualizationPanelClass = 'collapsible-panel-main-panel';
+ const unifiedFilterValues = {};
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <vnfSearch
+ vnfFilters={vnfFilters}
+ unifiedFilterValues={unifiedFilterValues}
+ vnfVisualizationPanelClass={vnfVisualizationPanelClass}
+ />
+ );
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ });
+})
+//
+// describe('VnfSearch - Render React Component (wrapped in <Provider>)', () => {
+// const initialState = {
+// vnfSearch: {}
+// };
+// const mockStore = configureStore();
+// let store, wrapper;
+//
+// beforeEach( () => {
+// store = mockStore(initialState);
+// wrapper = mount(<Provider store={store}><ConnectedVnfSearch /></Provider>);
+// })
+//
+// it('Render the connected component', () => {
+// expect(wrapper.find(ConnectedVnfSearch).length).toEqual(1);
+// });
+//
+// it('Validate props from store', () => {
+// expect(wrapper.find(VnfSearchNfRoleVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback);
+// expect(wrapper.find(VnfSearchNfRoleVisualization).props().processedNfRoleCountChartData).toEqual(initialState.vnfSearch.processedNfRoleCountChartData);
+// });
+// })
diff --git a/src/app/vnfSearch/VnfSearchActions.js b/src/app/vnfSearch/VnfSearchActions.js
index 4ca149d..20290d6 100644
--- a/src/app/vnfSearch/VnfSearchActions.js
+++ b/src/app/vnfSearch/VnfSearchActions.js
@@ -39,9 +39,6 @@ import {
} from 'app/globalInlineMessageBar/GlobalInlineMessageBarActions.js';
import {MESSAGE_LEVEL_WARNING} from 'utils/GlobalConstants.js';
-let fetch = require('node-fetch');
-fetch.Promise = require('es6-promise').Promise;
-
const itemKeyWord = 'key';
const countKeyWord = 'doc_count';
diff --git a/src/app/vnfSearch/VnfSearchActions.test.js b/src/app/vnfSearch/VnfSearchActions.test.js
new file mode 100644
index 0000000..927e6ab
--- /dev/null
+++ b/src/app/vnfSearch/VnfSearchActions.test.js
@@ -0,0 +1,215 @@
+import configureStore from 'redux-mock-store';
+import thunk from 'redux-thunk'
+import fetchMock from 'fetch-mock';
+
+import {
+ processVnfFilterPanelCollapse,
+ clearVnfSearchData,
+ setNotificationText,
+ processVnfVisualizationsOnFilterChange
+} from './VnfSearchActions.js';
+import {
+ vnfActionTypes,
+ CHART_PROV_STATUS,
+ CHART_ORCH_STATUS,
+ CHART_NF_TYPE,
+ CHART_NF_ROLE,
+ TOTAL_VNF_COUNT,
+ VNF_FILTER_EMPTY_RESULT
+} from 'app/vnfSearch/VnfSearchConstants.js';
+import { globalInlineMessageBarActionTypes } from 'app/globalInlineMessageBar/GlobalInlineMessageBarConstants.js';
+import { ERROR_RETRIEVING_DATA } from 'app/networking/NetworkConstants.js';
+
+describe('VnfSearchAction - Action Tests', () => {
+ it('Action: processVnfFilterPanelCollapse - open', () => {
+ const result = processVnfFilterPanelCollapse(true);
+ expect(result).toEqual({
+ type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED,
+ data: {
+ vnfVisualizationPanelClass: 'collapsible-panel-main-panel vertical-filter-panel-is-open'
+ }
+ });
+ });
+
+ it('Action: processVnfFilterPanelCollapse - close', () => {
+ const result = processVnfFilterPanelCollapse(false);
+ expect(result).toEqual({
+ type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED,
+ data: {
+ vnfVisualizationPanelClass: 'collapsible-panel-main-panel'
+ }
+ });
+ });
+
+ it('Action: clearVnfSearchData', () => {
+ const result = clearVnfSearchData();
+ expect(result).toEqual({
+ type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
+ data: {
+ count: '',
+ provStatusData: CHART_PROV_STATUS.emptyData,
+ orchStatusData: CHART_ORCH_STATUS.emptyData,
+ nfTypeData: CHART_NF_TYPE.emptyData,
+ nfRoleData: CHART_NF_ROLE.emptyData
+ }
+ });
+ });
+
+ it('Action: setNotificationText - with message', () => {
+ const middlewares = [thunk];
+ const mockStore = configureStore(middlewares);
+ const store = mockStore({ vnfSearch: {} });
+ store.dispatch(setNotificationText('test error message', 'WARNING'));
+ const actions = store.getActions();
+ expect(actions).toEqual([{
+ type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE,
+ data: {
+ msgText: 'test error message',
+ msgSeverity: 'WARNING'
+ }
+ }]);
+ });
+
+ it('Action: processVnfVisualizationsOnFilterChange - data for filter values', () => {
+ const middlewares = [thunk];
+ const mockStore = configureStore(middlewares);
+ const store = mockStore({ vnfSearch: {} });
+ const filterValueMap = {
+ 1: 'Running',
+ 2: 'Junk',
+ 7: 'Blah',
+ 8: 'Doh'
+ };
+ const expectedActions = [
+ { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK },
+ { type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE },
+ {
+ type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
+ data: {
+ count: 10,
+ provStatusData: {
+ values: [
+ { x: 'junk', y: 10 }
+ ]
+ },
+ orchStatusData: {
+ values: [
+ { x: 'running', y: 10 }
+ ]
+ },
+ nfTypeData: {
+ values: [
+ { x: 'doh', y: 10 }
+ ]
+ },
+ nfRoleData: {
+ values: [
+ { x: 'blah', y: 10 }
+ ]
+ }
+ }
+ },
+ { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK }
+ ];
+ fetchMock.mock('*', {
+ "total": 10,
+ "aggregations":{
+ "nf-role":[{"doc_count":10,"key":"blah"}],
+ "nf-type":[{"doc_count":10,"key":"doh"}],
+ "prov-status":[{"doc_count":10,"key":"junk"}],
+ "orchestration-status":[{"doc_count":10,"key":"running"}]
+ }
+ });
+
+ return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap))
+ .then( () => {
+ const actions = store.getActions();
+ expect(actions).toEqual(expectedActions);
+ fetchMock.restore();
+ });
+ });
+
+ it('Action: processVnfVisualizationsOnFilterChange - no data for filter values', () => {
+ const middlewares = [thunk];
+ const mockStore = configureStore(middlewares);
+ const store = mockStore({ vnfSearch: {} });
+ const filterValueMap = {
+ 1: 'Running',
+ 2: 'Junk',
+ 7: '',
+ 8: 'Doh'
+ };
+ const expectedActions = [
+ { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK },
+ { type: globalInlineMessageBarActionTypes.SET_GLOBAL_MESSAGE,
+ data: { msgSeverity: "warning", msgText: VNF_FILTER_EMPTY_RESULT }
+ },
+ {
+ type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
+ data: {
+ count: TOTAL_VNF_COUNT.emptyData,
+ provStatusData: CHART_PROV_STATUS.emptyData,
+ orchStatusData: CHART_ORCH_STATUS.emptyData,
+ nfTypeData: CHART_NF_TYPE.emptyData,
+ nfRoleData: CHART_NF_ROLE.emptyData
+ }
+ },
+ { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK }
+ ];
+ fetchMock.mock('*', {
+ "total": 0,
+ "aggregations":{
+ "nf-role":[],
+ "nf-type":[],
+ "prov-status":[],
+ "orchestration-status":[]
+ }
+ });
+
+ return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap))
+ .then( () => {
+ const actions = store.getActions();
+ expect(actions).toEqual(expectedActions);
+ fetchMock.restore();
+ });
+ });
+
+ it('Action: processVnfVisualizationsOnFilterChange - network error', () => {
+ const middlewares = [thunk];
+ const mockStore = configureStore(middlewares);
+ const store = mockStore({ vnfSearch: {} });
+ const filterValueMap = {
+ 1: 'Running',
+ 2: 'Junk',
+ 7: 'Blah',
+ 8: 'Doh'
+ };
+ const expectedActions = [
+ { type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK },
+ { type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK },
+ {
+ type: vnfActionTypes.VNF_NETWORK_ERROR,
+ data: { errorMsg: ERROR_RETRIEVING_DATA }
+ }
+ ];
+ fetchMock.mock('*', 503);
+
+ return store.dispatch(processVnfVisualizationsOnFilterChange(filterValueMap))
+ .then( () => {
+ const actions = store.getActions();
+ expect(actions).toEqual(expectedActions);
+ fetchMock.restore();
+ });
+ });
+
+ it('Action: setNotificationText - no message', () => {
+ const middlewares = [thunk];
+ const mockStore = configureStore(middlewares);
+ const store = mockStore({ vnfSearch: {} });
+ store.dispatch(setNotificationText('', ''));
+ const actions = store.getActions();
+ expect(actions).toEqual([{
+ type: globalInlineMessageBarActionTypes.CLEAR_GLOBAL_MESSAGE
+ }]);
+ });
+})
diff --git a/src/app/vnfSearch/VnfSearchNfRoleVisualization.jsx b/src/app/vnfSearch/VnfSearchNfRoleVisualization.jsx
index 5d09ac4..a71b2ab 100644
--- a/src/app/vnfSearch/VnfSearchNfRoleVisualization.jsx
+++ b/src/app/vnfSearch/VnfSearchNfRoleVisualization.jsx
@@ -48,7 +48,7 @@ let mapStateToProps = ({vnfSearch}) => {
};
};
-class VnfSearchNfRoleVisualization extends Component {
+export class VnfSearchNfRoleVisualization extends Component {
static propTypes = {
processedNfRoleCountChartData: React.PropTypes.object,
enableBusyFeedback: React.PropTypes.bool
diff --git a/src/app/vnfSearch/VnfSearchNfRoleVisualization.test.js b/src/app/vnfSearch/VnfSearchNfRoleVisualization.test.js
new file mode 100644
index 0000000..cf94925
--- /dev/null
+++ b/src/app/vnfSearch/VnfSearchNfRoleVisualization.test.js
@@ -0,0 +1,154 @@
+import React from 'react';
+import { shallow, mount } from 'enzyme';
+import {Provider} from 'react-redux'
+import configureStore from 'redux-mock-store';
+import { BarChart } from 'recharts';
+
+import ConnectedVnfSearchNfRoleVisualization,
+ { VnfSearchNfRoleVisualization } from './VnfSearchNfRoleVisualization.jsx';
+import { CHART_NF_ROLE } from './VnfSearchConstants.js';
+import Spinner from 'utils/SpinnerContainer.jsx';
+
+describe('VnfSearchNfRoleVisualization - Shallow render of component', () => {
+ let wrapper;
+ const processedNfRoleCountChartDataProp = {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchNfRoleVisualization
+ enableBusyFeedback={false}
+ processedNfRoleCountChartData={processedNfRoleCountChartDataProp}
+ />
+ );
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(wrapper.hasClass('visualizations')).toEqual(true);
+ });
+
+ it('Verify Spinner is present but not visible', () => {
+ expect(wrapper.find(Spinner)).toHaveLength(1);
+ expect(wrapper.find(Spinner).props().loading).toEqual(false);
+ });
+
+ it('Verify BarChart is displayed', () => {
+ expect(wrapper.find(BarChart)).toHaveLength(1);
+ expect(wrapper.find(BarChart).props().data).toEqual(processedNfRoleCountChartDataProp.values);
+ });
+})
+
+describe('VnfSearchNfRoleVisualization - Shallow render of component with no chart data', () => {
+ let wrapper;
+ const processedNfRoleCountChartDataProp = {
+ values: null
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchNfRoleVisualization
+ enableBusyFeedback={false}
+ processedNfRoleCountChartData={processedNfRoleCountChartDataProp}
+ />
+ );
+ })
+
+ it('Visualization graph hidden', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true);
+ });
+})
+
+describe('VnfSearchNfRoleVisualization - Shallow render of component with busy feedback', () => {
+ let wrapper;
+ const processedNfRoleCountChartDataProp = {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchNfRoleVisualization
+ enableBusyFeedback={true}
+ processedNfRoleCountChartData={processedNfRoleCountChartDataProp}
+ />
+ );
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(wrapper.hasClass('visualizations')).toEqual(true);
+ });
+
+ it('Verify Spinner is present and visible', () => {
+ expect(wrapper.find(Spinner)).toHaveLength(1);
+ expect(wrapper.find(Spinner).props().loading).toEqual(true);
+ });
+
+ it('Verify BarChart is displayed', () => {
+ expect(wrapper.find(BarChart)).toHaveLength(1);
+ expect(wrapper.find(BarChart).props().data).toEqual(processedNfRoleCountChartDataProp.values);
+ });
+})
+
+describe('VnfSearchNfRoleVisualization - Render React Component (wrapped in <Provider>)', () => {
+ const initialState = {
+ vnfSearch: {
+ processedNfRoleCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ enableBusyFeedback: false
+ }
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = mount(<Provider store={store}><ConnectedVnfSearchNfRoleVisualization /></Provider>);
+ })
+
+ it('Render the connected component', () => {
+ expect(wrapper.find(ConnectedVnfSearchNfRoleVisualization).length).toEqual(1);
+ });
+
+ it('Validate props from store', () => {
+ expect(wrapper.find(VnfSearchNfRoleVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback);
+ expect(wrapper.find(VnfSearchNfRoleVisualization).props().processedNfRoleCountChartData).toEqual(initialState.vnfSearch.processedNfRoleCountChartData);
+ });
+})
+
+describe('VnfSearchNfRoleVisualization - Render React Component (wrapped in <Provider>) with default props', () => {
+ const initialState = {
+ vnfSearch: {}
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = mount(<Provider store={store}><ConnectedVnfSearchNfRoleVisualization /></Provider>);
+ })
+
+ it('Render the connected component', () => {
+ expect(wrapper.find(ConnectedVnfSearchNfRoleVisualization).length).toEqual(1);
+ });
+
+ it('Validate default props loaded', () => {
+ expect(wrapper.find(VnfSearchNfRoleVisualization).props().enableBusyFeedback).toEqual(false);
+ expect(wrapper.find(VnfSearchNfRoleVisualization).props().processedNfRoleCountChartData).toEqual(CHART_NF_ROLE.emptyData);
+ });
+})
diff --git a/src/app/vnfSearch/VnfSearchNfTypeVisualization.jsx b/src/app/vnfSearch/VnfSearchNfTypeVisualization.jsx
index 5b540d9..492d1c9 100644
--- a/src/app/vnfSearch/VnfSearchNfTypeVisualization.jsx
+++ b/src/app/vnfSearch/VnfSearchNfTypeVisualization.jsx
@@ -48,7 +48,7 @@ let mapStateToProps = ({vnfSearch}) => {
};
};
-class VnfSearchNfTypeVisualization extends Component {
+export class VnfSearchNfTypeVisualization extends Component {
static propTypes = {
processedNfTypeCountChartData: React.PropTypes.object,
enableBusyFeedback: React.PropTypes.bool
diff --git a/src/app/vnfSearch/VnfSearchNfTypeVisualization.test.js b/src/app/vnfSearch/VnfSearchNfTypeVisualization.test.js
new file mode 100644
index 0000000..bbb2907
--- /dev/null
+++ b/src/app/vnfSearch/VnfSearchNfTypeVisualization.test.js
@@ -0,0 +1,154 @@
+import React from 'react';
+import { shallow, mount } from 'enzyme';
+import {Provider} from 'react-redux'
+import configureStore from 'redux-mock-store';
+import { BarChart } from 'recharts';
+
+import ConnectedVnfSearchNfTypeVisualization,
+ { VnfSearchNfTypeVisualization } from './VnfSearchNfTypeVisualization.jsx';
+import { CHART_NF_TYPE } from './VnfSearchConstants.js';
+import Spinner from 'utils/SpinnerContainer.jsx';
+
+describe('VnfSearchNfTypeVisualization - Shallow render of component', () => {
+ let wrapper;
+ const processedNfTypeCountChartDataProp = {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchNfTypeVisualization
+ enableBusyFeedback={false}
+ processedNfTypeCountChartData={processedNfTypeCountChartDataProp}
+ />
+ );
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(wrapper.hasClass('visualizations')).toEqual(true);
+ });
+
+ it('Verify Spinner is present but not visible', () => {
+ expect(wrapper.find(Spinner)).toHaveLength(1);
+ expect(wrapper.find(Spinner).props().loading).toEqual(false);
+ });
+
+ it('Verify BarChart is displayed', () => {
+ expect(wrapper.find(BarChart)).toHaveLength(1);
+ expect(wrapper.find(BarChart).props().data).toEqual(processedNfTypeCountChartDataProp.values);
+ });
+})
+
+describe('VnfSearchNfTypeVisualization - Shallow render of component with no chart data', () => {
+ let wrapper;
+ const processedNfTypeCountChartDataProp = {
+ values: null
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchNfTypeVisualization
+ enableBusyFeedback={false}
+ processedNfTypeCountChartData={processedNfTypeCountChartDataProp}
+ />
+ );
+ })
+
+ it('Visualization graph hidden', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true);
+ });
+})
+
+describe('VnfSearchNfTypeVisualization - Shallow render of component with busy feedback', () => {
+ let wrapper;
+ const processedNfTypeCountChartDataProp = {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchNfTypeVisualization
+ enableBusyFeedback={true}
+ processedNfTypeCountChartData={processedNfTypeCountChartDataProp}
+ />
+ );
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(wrapper.hasClass('visualizations')).toEqual(true);
+ });
+
+ it('Verify Spinner is present and visible', () => {
+ expect(wrapper.find(Spinner)).toHaveLength(1);
+ expect(wrapper.find(Spinner).props().loading).toEqual(true);
+ });
+
+ it('Verify BarChart is displayed', () => {
+ expect(wrapper.find(BarChart)).toHaveLength(1);
+ expect(wrapper.find(BarChart).props().data).toEqual(processedNfTypeCountChartDataProp.values);
+ });
+})
+
+describe('VnfSearchNfTypeVisualization - Render React Component (wrapped in <Provider>)', () => {
+ const initialState = {
+ vnfSearch: {
+ processedNfTypeCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ enableBusyFeedback: false
+ }
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = mount(<Provider store={store}><ConnectedVnfSearchNfTypeVisualization /></Provider>);
+ })
+
+ it('Render the connected component', () => {
+ expect(wrapper.find(ConnectedVnfSearchNfTypeVisualization).length).toEqual(1);
+ });
+
+ it('Validate props from store', () => {
+ expect(wrapper.find(VnfSearchNfTypeVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback);
+ expect(wrapper.find(VnfSearchNfTypeVisualization).props().processedNfTypeCountChartData).toEqual(initialState.vnfSearch.processedNfTypeCountChartData);
+ });
+})
+
+describe('VnfSearchNfTypeVisualization - Render React Component (wrapped in <Provider>) with default props', () => {
+ const initialState = {
+ vnfSearch: {}
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = mount(<Provider store={store}><ConnectedVnfSearchNfTypeVisualization /></Provider>);
+ })
+
+ it('Render the connected component', () => {
+ expect(wrapper.find(ConnectedVnfSearchNfTypeVisualization).length).toEqual(1);
+ });
+
+ it('Validate default props loaded', () => {
+ expect(wrapper.find(VnfSearchNfTypeVisualization).props().enableBusyFeedback).toEqual(false);
+ expect(wrapper.find(VnfSearchNfTypeVisualization).props().processedNfTypeCountChartData).toEqual(CHART_NF_TYPE.emptyData);
+ });
+})
diff --git a/src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx b/src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx
index be13d07..8dc25ca 100644
--- a/src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx
+++ b/src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.jsx
@@ -48,7 +48,7 @@ let mapStateToProps = ({vnfSearch}) => {
};
};
-class VnfSearchOrchStatusVisualizations extends Component {
+export class VnfSearchOrchStatusVisualizations extends Component {
static propTypes = {
processedOrchStatusCountChartData: React.PropTypes.object,
enableBusyFeedback: React.PropTypes.bool
diff --git a/src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js b/src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js
new file mode 100644
index 0000000..1257f3a
--- /dev/null
+++ b/src/app/vnfSearch/VnfSearchOrchestratedStatusVisualization.test.js
@@ -0,0 +1,154 @@
+import React from 'react';
+import { shallow, mount } from 'enzyme';
+import {Provider} from 'react-redux'
+import configureStore from 'redux-mock-store';
+import { BarChart } from 'recharts';
+
+import ConnectedVnfSearchOrchStatusVisualizations,
+ { VnfSearchOrchStatusVisualizations } from './VnfSearchOrchestratedStatusVisualization.jsx';
+import { CHART_ORCH_STATUS } from './VnfSearchConstants.js';
+import Spinner from 'utils/SpinnerContainer.jsx';
+
+describe('VnfSearchOrchStatusVisualizations - Shallow render of component', () => {
+ let wrapper;
+ const processedOrchStatusCountChartDataProp = {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchOrchStatusVisualizations
+ enableBusyFeedback={false}
+ processedOrchStatusCountChartData={processedOrchStatusCountChartDataProp}
+ />
+ );
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(wrapper.hasClass('visualizations')).toEqual(true);
+ });
+
+ it('Verify Spinner is present but not visible', () => {
+ expect(wrapper.find(Spinner)).toHaveLength(1);
+ expect(wrapper.find(Spinner).props().loading).toEqual(false);
+ });
+
+ it('Verify BarChart is displayed', () => {
+ expect(wrapper.find(BarChart)).toHaveLength(1);
+ expect(wrapper.find(BarChart).props().data).toEqual(processedOrchStatusCountChartDataProp.values);
+ });
+})
+
+describe('VnfSearchOrchStatusVisualizations - Shallow render of component with no chart data', () => {
+ let wrapper;
+ const processedOrchStatusCountChartDataProp = {
+ values: null
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchOrchStatusVisualizations
+ enableBusyFeedback={false}
+ processedOrchStatusCountChartData={processedOrchStatusCountChartDataProp}
+ />
+ );
+ })
+
+ it('Visualization graph hidden', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true);
+ });
+})
+
+describe('VnfSearchOrchStatusVisualizations - Shallow render of component with busy feedback', () => {
+ let wrapper;
+ const processedOrchStatusCountChartDataProp = {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchOrchStatusVisualizations
+ enableBusyFeedback={true}
+ processedOrchStatusCountChartData={processedOrchStatusCountChartDataProp}
+ />
+ );
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(wrapper.hasClass('visualizations')).toEqual(true);
+ });
+
+ it('Verify Spinner is present and visible', () => {
+ expect(wrapper.find(Spinner)).toHaveLength(1);
+ expect(wrapper.find(Spinner).props().loading).toEqual(true);
+ });
+
+ it('Verify BarChart is displayed', () => {
+ expect(wrapper.find(BarChart)).toHaveLength(1);
+ expect(wrapper.find(BarChart).props().data).toEqual(processedOrchStatusCountChartDataProp.values);
+ });
+})
+
+describe('VnfSearchOrchStatusVisualizations - Render React Component (wrapped in <Provider>)', () => {
+ const initialState = {
+ vnfSearch: {
+ processedOrchStatusCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ enableBusyFeedback: false
+ }
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = mount(<Provider store={store}><ConnectedVnfSearchOrchStatusVisualizations /></Provider>);
+ })
+
+ it('Render the connected component', () => {
+ expect(wrapper.find(ConnectedVnfSearchOrchStatusVisualizations).length).toEqual(1);
+ });
+
+ it('Validate props from store', () => {
+ expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback);
+ expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().processedOrchStatusCountChartData).toEqual(initialState.vnfSearch.processedOrchStatusCountChartData);
+ });
+})
+
+describe('VnfSearchOrchStatusVisualizations - Render React Component (wrapped in <Provider>) with default props', () => {
+ const initialState = {
+ vnfSearch: {}
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = mount(<Provider store={store}><ConnectedVnfSearchOrchStatusVisualizations /></Provider>);
+ })
+
+ it('Render the connected component', () => {
+ expect(wrapper.find(ConnectedVnfSearchOrchStatusVisualizations).length).toEqual(1);
+ });
+
+ it('Validate default props loaded', () => {
+ expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().enableBusyFeedback).toEqual(false);
+ expect(wrapper.find(VnfSearchOrchStatusVisualizations).props().processedOrchStatusCountChartData).toEqual(CHART_ORCH_STATUS.emptyData);
+ });
+})
diff --git a/src/app/vnfSearch/VnfSearchProvStatusVisualization.jsx b/src/app/vnfSearch/VnfSearchProvStatusVisualization.jsx
index a7c31c0..07ba988 100644
--- a/src/app/vnfSearch/VnfSearchProvStatusVisualization.jsx
+++ b/src/app/vnfSearch/VnfSearchProvStatusVisualization.jsx
@@ -48,7 +48,7 @@ let mapStateToProps = ({vnfSearch}) => {
};
};
-class VnfSearchProvStatusVisualization extends Component {
+export class VnfSearchProvStatusVisualization extends Component {
static propTypes = {
processedProvStatusCountChartData: React.PropTypes.object,
enableBusyFeedback: React.PropTypes.bool
diff --git a/src/app/vnfSearch/VnfSearchProvStatusVisualization.test.js b/src/app/vnfSearch/VnfSearchProvStatusVisualization.test.js
new file mode 100644
index 0000000..4812834
--- /dev/null
+++ b/src/app/vnfSearch/VnfSearchProvStatusVisualization.test.js
@@ -0,0 +1,154 @@
+import React from 'react';
+import { shallow, mount } from 'enzyme';
+import {Provider} from 'react-redux'
+import configureStore from 'redux-mock-store';
+import { BarChart } from 'recharts';
+
+import ConnectedVnfSearchProvStatusVisualization,
+ { VnfSearchProvStatusVisualization } from './VnfSearchProvStatusVisualization.jsx';
+import { CHART_PROV_STATUS } from './VnfSearchConstants.js';
+import Spinner from 'utils/SpinnerContainer.jsx';
+
+describe('VnfSearchProvStatusVisualization - Shallow render of component', () => {
+ let wrapper;
+ const processedProvStatusCountChartDataProp = {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchProvStatusVisualization
+ enableBusyFeedback={false}
+ processedProvStatusCountChartData={processedProvStatusCountChartDataProp}
+ />
+ );
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(wrapper.hasClass('visualizations')).toEqual(true);
+ });
+
+ it('Verify Spinner is present but not visible', () => {
+ expect(wrapper.find(Spinner)).toHaveLength(1);
+ expect(wrapper.find(Spinner).props().loading).toEqual(false);
+ });
+
+ it('Verify BarChart is displayed', () => {
+ expect(wrapper.find(BarChart)).toHaveLength(1);
+ expect(wrapper.find(BarChart).props().data).toEqual(processedProvStatusCountChartDataProp.values);
+ });
+})
+
+describe('VnfSearchProvStatusVisualization - Shallow render of component with no chart data', () => {
+ let wrapper;
+ const processedProvStatusCountChartDataProp = {
+ values: null
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchProvStatusVisualization
+ enableBusyFeedback={false}
+ processedProvStatusCountChartData={processedProvStatusCountChartDataProp}
+ />
+ );
+ })
+
+ it('Visualization graph hidden', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true);
+ });
+})
+
+describe('VnfSearchProvStatusVisualization - Shallow render of component with busy feedback', () => {
+ let wrapper;
+ const processedProvStatusCountChartDataProp = {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ };
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchProvStatusVisualization
+ enableBusyFeedback={true}
+ processedProvStatusCountChartData={processedProvStatusCountChartDataProp}
+ />
+ );
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(wrapper.hasClass('visualizations')).toEqual(true);
+ });
+
+ it('Verify Spinner is present and visible', () => {
+ expect(wrapper.find(Spinner)).toHaveLength(1);
+ expect(wrapper.find(Spinner).props().loading).toEqual(true);
+ });
+
+ it('Verify BarChart is displayed', () => {
+ expect(wrapper.find(BarChart)).toHaveLength(1);
+ expect(wrapper.find(BarChart).props().data).toEqual(processedProvStatusCountChartDataProp.values);
+ });
+})
+
+describe('VnfSearchProvStatusVisualization - Render React Component (wrapped in <Provider>)', () => {
+ const initialState = {
+ vnfSearch: {
+ processedProvStatusCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ enableBusyFeedback: false
+ }
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = mount(<Provider store={store}><ConnectedVnfSearchProvStatusVisualization /></Provider>);
+ })
+
+ it('Render the connected component', () => {
+ expect(wrapper.find(ConnectedVnfSearchProvStatusVisualization).length).toEqual(1);
+ });
+
+ it('Validate props from store', () => {
+ expect(wrapper.find(VnfSearchProvStatusVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback);
+ expect(wrapper.find(VnfSearchProvStatusVisualization).props().processedProvStatusCountChartData).toEqual(initialState.vnfSearch.processedProvStatusCountChartData);
+ });
+})
+
+describe('VnfSearchProvStatusVisualization - Render React Component (wrapped in <Provider>) with default props', () => {
+ const initialState = {
+ vnfSearch: {}
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = mount(<Provider store={store}><ConnectedVnfSearchProvStatusVisualization /></Provider>);
+ })
+
+ it('Render the connected component', () => {
+ expect(wrapper.find(ConnectedVnfSearchProvStatusVisualization).length).toEqual(1);
+ });
+
+ it('Validate default props loaded', () => {
+ expect(wrapper.find(VnfSearchProvStatusVisualization).props().enableBusyFeedback).toEqual(false);
+ expect(wrapper.find(VnfSearchProvStatusVisualization).props().processedProvStatusCountChartData).toEqual(CHART_PROV_STATUS.emptyData);
+ });
+})
diff --git a/src/app/vnfSearch/VnfSearchReducer.test.js b/src/app/vnfSearch/VnfSearchReducer.test.js
new file mode 100644
index 0000000..ff06770
--- /dev/null
+++ b/src/app/vnfSearch/VnfSearchReducer.test.js
@@ -0,0 +1,438 @@
+import VnfSearchReducer from './VnfSearchReducer.js';
+import {
+ vnfActionTypes,
+ CHART_ORCH_STATUS,
+ CHART_PROV_STATUS,
+ CHART_NF_ROLE,
+ CHART_NF_TYPE,
+ TOTAL_VNF_COUNT
+} from './VnfSearchConstants.js';
+import {ERROR_RETRIEVING_DATA} from 'app/networking/NetworkConstants.js';
+import {
+ filterBarActionTypes,
+ MESSAGE_LEVEL_DANGER
+} from 'utils/GlobalConstants.js';
+import {
+ globalAutoCompleteSearchBarActionTypes
+} from 'app/globalAutoCompleteSearchBar/GlobalAutoCompleteSearchBarConstants.js';
+
+describe('VnfSearchReducer - Reducer Action Type Tests', () => {
+ it('Action Type: VNF_NETWORK_ERROR', () => {
+ const action = {
+ type: vnfActionTypes.VNF_NETWORK_ERROR
+ };
+ let state = {
+ processedProvStatusCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ processedOrchStatusCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ processedNfTypeCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ processedNfRoleCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ count: 20,
+ feedbackMsgText: '',
+ feedbackMsgSeverity: ''
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData,
+ processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData,
+ processedNfTypeCountChartData: CHART_NF_TYPE.emptyData,
+ processedNfRoleCountChartData: CHART_NF_ROLE.emptyData,
+ count: TOTAL_VNF_COUNT.emptyValue,
+ feedbackMsgText: ERROR_RETRIEVING_DATA,
+ feedbackMsgSeverity: MESSAGE_LEVEL_DANGER
+ });
+ });
+
+ it('Action Type: SEARCH_WARNING_EVENT', () => {
+ const action = {
+ type: globalAutoCompleteSearchBarActionTypes.SEARCH_WARNING_EVENT
+ };
+ let state = {
+ processedProvStatusCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ processedOrchStatusCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ processedNfTypeCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ processedNfRoleCountChartData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ count: 20,
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ processedProvStatusCountChartData: CHART_PROV_STATUS.emptyData,
+ processedOrchStatusCountChartData: CHART_ORCH_STATUS.emptyData,
+ processedNfTypeCountChartData: CHART_NF_TYPE.emptyData,
+ processedNfRoleCountChartData: CHART_NF_ROLE.emptyData,
+ count: TOTAL_VNF_COUNT.emptyValue,
+ });
+ });
+
+ it('Action Type: NEW_SELECTIONS', () => {
+ const action = {
+ type: filterBarActionTypes.NEW_SELECTIONS,
+ data: {
+ selectedValuesMap: [
+ { filter1: ['someValue'] }
+ ],
+ unifiedValues: [
+ { filter1: ['someValue', 'someOtherValue']}
+ ]
+ }
+ };
+ let state = {
+ vnfFilterValues: {},
+ unifiedFilterValues: {}
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ vnfFilterValues: action.data.selectedValuesMap,
+ unifiedFilterValues: action.data.unifiedValues
+ });
+ });
+
+ it('Action Type: SET_UNIFIED_VALUES', () => {
+ const action = {
+ type: filterBarActionTypes.SET_UNIFIED_VALUES,
+ data: {
+ unifiedValues: [
+ { filter1: ['someValue', 'someOtherValue']}
+ ]
+ }
+ };
+ let state = {
+ unifiedFilterValues: {}
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ unifiedFilterValues: action.data
+ });
+ });
+
+ it('Action Type: VNF_SEARCH_RESULTS_RECEIVED', () => {
+ const action = {
+ type: vnfActionTypes.VNF_SEARCH_RESULTS_RECEIVED,
+ data: {
+ provStatusData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ orchStatusData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ nfTypeData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ nfRoleData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ count: 25,
+ }
+ };
+ let state = {
+ processedProvStatusCountChartData: {},
+ processedOrchStatusCountChartData: {},
+ processedNfTypeCountChartData: {},
+ processedNfRoleCountChartData: {},
+ count: 0,
+ feedbackMsgText: 'some error msg',
+ feedbackMsgSeverity: 'someSeverityLevel'
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ processedProvStatusCountChartData: action.data.provStatusData,
+ processedOrchStatusCountChartData: action.data.orchStatusData,
+ processedNfTypeCountChartData: action.data.nfTypeData,
+ processedNfRoleCountChartData: action.data.nfRoleData,
+ count: action.data.count,
+ feedbackMsgText: '',
+ feedbackMsgSeverity: ''
+ });
+ });
+
+ it('Action Type: VNF_FILTER_PANEL_TOGGLED', () => {
+ const action = {
+ type: vnfActionTypes.VNF_FILTER_PANEL_TOGGLED,
+ data: {
+ vnfVisualizationPanelClass: 'hide',
+ }
+ };
+ let state = {
+ vnfVisualizationPanelClass: 'show'
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ vnfVisualizationPanelClass: 'hide'
+ });
+ });
+
+ it('Action Type: VNF_SEARCH_FILTERS_RECEIVED', () => {
+ const action = {
+ type: vnfActionTypes.VNF_SEARCH_FILTERS_RECEIVED,
+ data: [
+ { filter1: 'value 1' },
+ { filter2: 'value 2' }
+ ]
+ };
+ let state = {
+ vnfFilters: []
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ vnfFilters: action.data
+ });
+ });
+
+ it('Action Type: SET_NON_CONVERTED_VALUES', () => {
+ const action = {
+ type: filterBarActionTypes.SET_NON_CONVERTED_VALUES,
+ data: [
+ { value1: 'abc' },
+ { value2: 'xyz' }
+ ]
+ };
+ let state = {
+ nonConvertedFilters: []
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ nonConvertedFilters: action.data
+ });
+ });
+
+ it('Action Type: SET_CONVERTED_VALUES', () => {
+ const action = {
+ type: filterBarActionTypes.SET_CONVERTED_VALUES,
+ data: {
+ convertedValues: {
+ value1: 'abc',
+ value2: 'xyz'
+ },
+ nonConvertedValues: {
+ value1: 123,
+ value2: 456
+ }
+ }
+ };
+ let state = {
+ nonConvertedFilters: {
+ filter1: 'one',
+ filter2: 'two'
+ },
+ unifiedFilterValues: {},
+ vnfFilterValues: {}
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ nonConvertedFilters: {},
+ unifiedFilterValues: action.data.convertedValues,
+ vnfFilterValues: action.data.nonConvertedValues
+ });
+ });
+
+ it('Action Type: VNF_ACTIVATE_BUSY_FEEDBACK', () => {
+ const action = {
+ type: vnfActionTypes.VNF_ACTIVATE_BUSY_FEEDBACK
+ };
+ let state = {
+ enableBusyFeedback: false
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ enableBusyFeedback: true
+ });
+ });
+
+ it('Action Type: VNF_DISABLE_BUSY_FEEDBACK', () => {
+ const action = {
+ type: vnfActionTypes.VNF_DISABLE_BUSY_FEEDBACK
+ };
+ let state = {
+ enableBusyFeedback: true
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ enableBusyFeedback: false
+ });
+ });
+
+ it('Action Type: CLEAR_FILTERS', () => {
+ const action = {
+ type: filterBarActionTypes.CLEAR_FILTERS
+ };
+ let state = {
+ vnfFilters: {
+ filter1: 'filterName1'
+ },
+ vnfFilterValues: {
+ filter1: 'value 1'
+ },
+ nonConvertedFilters: {
+ nonConvertedFilter1: 'some fitler props'
+ },
+ unifiedFilterValues: {
+ unifiedFilter1: 'some unified props'
+ }
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ vnfFilters: {},
+ vnfFilterValues: {},
+ nonConvertedFilters: {},
+ unifiedFilterValues: {}
+ });
+ });
+
+ it('Invalid Action Type', () => {
+ const action = {
+ type: 'Nonexistent Action Type',
+ };
+ let state = {
+ vnfFilters: {
+ filter1: 'filterName1'
+ },
+ vnfFilterValues: {
+ filter1: 'value 1'
+ },
+ nonConvertedFilters: {
+ nonConvertedFilter1: 'some fitler props'
+ },
+ unifiedFilterValues: {
+ unifiedFilter1: 'some unified props'
+ },
+ enableBusyFeedback: true,
+ provStatusData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ orchStatusData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ nfTypeData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ nfRoleData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ count: 25
+ };
+ state = VnfSearchReducer(state, action);
+ expect(state).toEqual({
+ vnfFilters: {
+ filter1: 'filterName1'
+ },
+ vnfFilterValues: {
+ filter1: 'value 1'
+ },
+ nonConvertedFilters: {
+ nonConvertedFilter1: 'some fitler props'
+ },
+ unifiedFilterValues: {
+ unifiedFilter1: 'some unified props'
+ },
+ enableBusyFeedback: true,
+ provStatusData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ orchStatusData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ nfTypeData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ nfRoleData: {
+ values: [
+ {x: 'col 1', y: 3},
+ {x: 'col 2', y: 7},
+ {x: 'col 3', y: 2}
+ ]
+ },
+ count: 25
+ });
+ });
+})
diff --git a/src/app/vnfSearch/VnfSearchTotalCountVisualization.jsx b/src/app/vnfSearch/VnfSearchTotalCountVisualization.jsx
index 3a767b9..3c73d22 100644
--- a/src/app/vnfSearch/VnfSearchTotalCountVisualization.jsx
+++ b/src/app/vnfSearch/VnfSearchTotalCountVisualization.jsx
@@ -38,7 +38,7 @@ let mapStateToProps = ({vnfSearch}) => {
};
};
-class VnfSearchTotalCountVisualization extends Component {
+export class VnfSearchTotalCountVisualization extends Component {
static propTypes = {
count: React.PropTypes.oneOfType([
React.PropTypes.string,
diff --git a/src/app/vnfSearch/VnfSearchTotalCountVisualization.test.js b/src/app/vnfSearch/VnfSearchTotalCountVisualization.test.js
new file mode 100644
index 0000000..e891c12
--- /dev/null
+++ b/src/app/vnfSearch/VnfSearchTotalCountVisualization.test.js
@@ -0,0 +1,131 @@
+import React from 'react';
+import { shallow, mount } from 'enzyme';
+import {Provider} from 'react-redux'
+import configureStore from 'redux-mock-store';
+
+import ConnectedVnfSearchTotalCountVisualization,
+ { VnfSearchTotalCountVisualization } from './VnfSearchTotalCountVisualization.jsx';
+import { TOTAL_VNF_COUNT } from './VnfSearchConstants.js';
+import Spinner from 'utils/SpinnerContainer.jsx';
+
+describe('VnfSearchTotalCountVisualization - Shallow render of component', () => {
+ let wrapper;
+ const countProp = 25;
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchTotalCountVisualization
+ enableBusyFeedback={false}
+ count={countProp}
+ />
+ );
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(wrapper.hasClass('visualizations')).toEqual(true);
+ });
+
+ it('Verify Spinner is present but not visible', () => {
+ expect(wrapper.find(Spinner)).toHaveLength(1);
+ expect(wrapper.find(Spinner).props().loading).toEqual(false);
+ });
+
+ it('Verify total count is displayed', () => {
+ expect(wrapper.contains(<span>{countProp}</span>)).toBe(true);
+ });
+})
+
+describe('VnfSearchTotalCountVisualization - Shallow render of component with no chart data', () => {
+ let wrapper;
+ const countProp = null;
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchTotalCountVisualization
+ enableBusyFeedback={false}
+ count={countProp}
+ />
+ );
+ })
+
+ it('Visualization graph hidden', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(['visualizations', 'hidden'].every(className => wrapper.hasClass(className))).toEqual(true);
+ });
+})
+
+describe('VnfSearchTotalCountVisualization - Shallow render of component with busy feedback', () => {
+ let wrapper;
+ const countProp = 25;
+
+ beforeEach( () => {
+ wrapper = shallow(
+ <VnfSearchTotalCountVisualization
+ enableBusyFeedback={true}
+ count={countProp}
+ />
+ );
+ })
+
+ it('Render basic component', () => {
+ expect(wrapper.length).toEqual(1);
+ expect(wrapper.hasClass('visualizations')).toEqual(true);
+ });
+
+ it('Verify Spinner is present and visible', () => {
+ expect(wrapper.find(Spinner)).toHaveLength(1);
+ expect(wrapper.find(Spinner).props().loading).toEqual(true);
+ });
+
+ it('Verify total count is displayed', () => {
+ expect(wrapper.contains(<span>{countProp}</span>)).toBe(true);
+ });
+})
+
+describe('VnfSearchTotalCountVisualization - Render React Component (wrapped in <Provider>)', () => {
+ const initialState = {
+ vnfSearch: {
+ count: 25,
+ enableBusyFeedback: false
+ }
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = mount(<Provider store={store}><ConnectedVnfSearchTotalCountVisualization /></Provider>);
+ })
+
+ it('Render the connected component', () => {
+ expect(wrapper.find(ConnectedVnfSearchTotalCountVisualization).length).toEqual(1);
+ });
+
+ it('Validate props from store', () => {
+ expect(wrapper.find(VnfSearchTotalCountVisualization).props().enableBusyFeedback).toEqual(initialState.vnfSearch.enableBusyFeedback);
+ expect(wrapper.find(VnfSearchTotalCountVisualization).props().count).toEqual(initialState.vnfSearch.count);
+ });
+})
+
+describe('VnfSearchTotalCountVisualization - Render React Component (wrapped in <Provider>) with default props', () => {
+ const initialState = {
+ vnfSearch: {}
+ };
+ const mockStore = configureStore();
+ let store, wrapper;
+
+ beforeEach( () => {
+ store = mockStore(initialState);
+ wrapper = mount(<Provider store={store}><ConnectedVnfSearchTotalCountVisualization /></Provider>);
+ })
+
+ it('Render the connected component', () => {
+ expect(wrapper.find(ConnectedVnfSearchTotalCountVisualization).length).toEqual(1);
+ });
+
+ it('Validate default props loaded', () => {
+ expect(wrapper.find(VnfSearchTotalCountVisualization).props().enableBusyFeedback).toEqual(false);
+ expect(wrapper.find(VnfSearchTotalCountVisualization).props().count).toEqual(TOTAL_VNF_COUNT.emptyValue);
+ });
+})
diff --git a/src/utils/DateTimeChartUtil.test.js b/src/utils/DateTimeChartUtil.test.js
new file mode 100644
index 0000000..b1e9d69
--- /dev/null
+++ b/src/utils/DateTimeChartUtil.test.js
@@ -0,0 +1,92 @@
+import {
+ sortDataByField,
+ dateFormatLocalTimeZoneMMDDYYYY,
+ dateFormatLocalTimeZoneYYYYMMDD,
+ getTicks,
+ getTicksData
+} from './DateTimeChartUtil.js';
+
+describe('DateTimeChartUtil Tests', () => {
+ it('sortDataByField', () => {
+ let initialData = [
+ {word: 'plum', number: 2},
+ {word: 'apple', number: 3},
+ {word: 'banana', number: 1}
+ ];
+
+ sortDataByField(initialData, 'number');
+ expect(initialData[0]['number']).toBe(1);
+ expect(initialData[0]['word']).toBe('banana');
+ expect(initialData[1]['number']).toBe(2);
+ expect(initialData[1]['word']).toBe('plum');
+ expect(initialData[2]['number']).toBe(3);
+ expect(initialData[2]['word']).toBe('apple');
+ });
+
+ it('dateFormatLocalTimeZoneMMDDYYYY', () => {
+ const timestamp = Date.parse('Mon, 25 Dec 1995 13:30:00 GMT');
+ let formattedDate = dateFormatLocalTimeZoneMMDDYYYY(timestamp);
+ expect(formattedDate).toBe('12/25/1995');
+ });
+
+ it('dateFormatLocalTimeZoneYYYYMMDD', () => {
+ const timestamp = Date.parse('Mon, 25 Dec 1995 13:30:00 GMT');
+ let formattedDate = dateFormatLocalTimeZoneYYYYMMDD(timestamp);
+ expect(formattedDate).toBe('1995-12-25');
+ });
+
+ it('getTicks', () => {
+ const timestamps = [
+ {timestamp: 1521691200000, date: 'Thu, 22 Mar 2018 04:00:00 GMT'},
+ {timestamp: 1521777600000, date: 'Thu, 23 Mar 2018 04:00:00 GMT'},
+ {timestamp: 1521950400000, date: 'Thu, 25 Mar 2018 04:00:00 GMT'},
+ {timestamp: 1522296000000, date: 'Thu, 29 Mar 2018 04:00:00 GMT'}
+ ];
+ let ticksPerDay = getTicks(timestamps, 'timestamp');
+ // expect 1 tick (timestamp) for each day between March 22 - March 29
+ expect(ticksPerDay.length).toBe(8);
+ });
+
+ it('getTicks - empty data', () => {
+ const timestamps = [];
+ let ticksPerDay = getTicks(timestamps, 'timestamp');
+ expect(ticksPerDay.length).toBe(0);
+ });
+
+ it('getTicksData', () => {
+ const timestamps = [
+ {timestamp: 1521691200000, date: 'Thu, 22 Mar 2018 04:00:00 GMT'},
+ {timestamp: 1521777600000, date: 'Thu, 23 Mar 2018 04:00:00 GMT'},
+ {timestamp: 1521950400000, date: 'Thu, 25 Mar 2018 04:00:00 GMT'},
+ {timestamp: 1522296000000, date: 'Thu, 29 Mar 2018 04:00:00 GMT'}
+ ];
+ let ticksPerDay = getTicks(timestamps, 'timestamp');
+ let mergedData = getTicksData(timestamps, ticksPerDay, 'timestamp');
+ // expect original 4 objects plus 4 additional objects for the missing days
+ // (4 additional objects will only have timestamp attribute, no date attribute)
+ expect(mergedData.length).toBe(8);
+ expect(mergedData[0]['timestamp']).toBe(1521691200000);
+ expect(mergedData[0]['date']).toBe('Thu, 22 Mar 2018 04:00:00 GMT');
+ expect(mergedData[1]['timestamp']).toBe(1521777600000);
+ expect(mergedData[1]['date']).toBe('Thu, 23 Mar 2018 04:00:00 GMT');
+ expect(mergedData[2]['timestamp']).toBe(1521950400000);
+ expect(mergedData[2]['date']).toBe('Thu, 25 Mar 2018 04:00:00 GMT');
+ expect(mergedData[3]['timestamp']).toBe(1522296000000);
+ expect(mergedData[3]['date']).toBe('Thu, 29 Mar 2018 04:00:00 GMT');
+ expect(mergedData[4]['timestamp']).toBeTruthy();
+ expect(mergedData[4]['date']).toBeUndefined();
+ expect(mergedData[5]['timestamp']).toBeTruthy();
+ expect(mergedData[5]['date']).toBeUndefined();
+ expect(mergedData[6]['timestamp']).toBeTruthy();
+ expect(mergedData[6]['date']).toBeUndefined();
+ expect(mergedData[7]['timestamp']).toBeTruthy();
+ expect(mergedData[7]['date']).toBeUndefined();
+ });
+
+ it('getTicksData - empty data', () => {
+ const timestamps = [];
+ let ticksPerDay = getTicks(timestamps, 'timestamp');
+ let mergedData = getTicksData(timestamps, ticksPerDay, 'timestamp');
+ expect(mergedData.length).toBe(0);
+ });
+})
diff --git a/src/utils/SpinnerContainer.jsx b/src/utils/SpinnerContainer.jsx
index d787554..1c8b1cd 100644
--- a/src/utils/SpinnerContainer.jsx
+++ b/src/utils/SpinnerContainer.jsx
@@ -47,4 +47,3 @@ SpinnerContainer.propTypes = {
SpinnerContainer.defaultProps = {
loading: false
};
-
diff --git a/src/utils/SpinnerContainer.test.js b/src/utils/SpinnerContainer.test.js
new file mode 100644
index 0000000..a217b8a
--- /dev/null
+++ b/src/utils/SpinnerContainer.test.js
@@ -0,0 +1,35 @@
+import React from 'react';
+import { ClipLoader } from 'react-spinners';
+import { mount } from 'enzyme';
+
+import SpinnerContainer from './SpinnerContainer.jsx';
+import {COLOR_BLUE} from 'utils/GlobalConstants.js';
+
+describe('SpinnerContainer', () => {
+ it('render spinner - visible', () => {
+ const spinner = mount(
+ <SpinnerContainer loading={true}>
+ <div class='test-div'>Testing Spinner Child</div>
+ <div class='test-div'>Testing Spinner Child</div>
+ </SpinnerContainer>
+ );
+ expect(spinner.props().loading).toEqual(true); // check that the props match
+ expect(spinner.find(ClipLoader)).toHaveLength(1); // ensure the ClipLoader is mounted
+ expect(spinner.find(ClipLoader).props().color).toEqual(COLOR_BLUE); // ensure spinner is blue
+ expect(spinner.find(ClipLoader).props().loading).toEqual(true); // ensure spinner is showing
+ expect(spinner.find('div.spinner-content')).toHaveLength(1); // ensure the children are grayed out
+ expect(spinner.find('div.spinner-content').children()).toHaveLength(2); // ensure number of children is accurate
+ });
+
+ it('render spinner - not visible', () => {
+ const spinner = mount(
+ <SpinnerContainer loading={false}>
+ <div class='test-div'>Testing Spinner</div>
+ </SpinnerContainer>
+ );
+ expect(spinner.props().loading).toEqual(false);
+ expect(spinner.find(ClipLoader)).toHaveLength(1);
+ expect(spinner.find(ClipLoader).props().loading).toEqual(false); // ensure spinner is not showing
+ expect(spinner.find('div.spinner-content')).toHaveLength(0);
+ });
+})
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);
- });
-
-});