aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/nfvo-components
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test/nfvo-components')
-rw-r--r--openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js9
-rw-r--r--openecomp-ui/test/nfvo-components/modal/globalModal.test.js8
-rw-r--r--openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js108
-rw-r--r--openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js128
-rw-r--r--openecomp-ui/test/nfvo-components/tree/tree.test.js31
5 files changed, 82 insertions, 202 deletions
diff --git a/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js b/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js
index e61261e09a..5f9f06b714 100644
--- a/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js
+++ b/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js
@@ -18,13 +18,15 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import TabulatedEditor from 'nfvo-components/editor/TabulatedEditor.jsx';
+import { Provider } from 'react-redux';
+import {storeCreator} from 'sdc-app/AppStore.js';
describe('Tabulated Editor test: ', function () {
-
+ const store = storeCreator();
it('basic view test', () => {
let renderer = TestUtils.createRenderer();
renderer.render(
- <TabulatedEditor><button>test</button></TabulatedEditor>
+ <Provider store={store}><TabulatedEditor><button>test</button></TabulatedEditor></Provider>
);
let renderedOutput = renderer.getRenderOutput();
expect(renderedOutput).toBeTruthy();
@@ -41,11 +43,12 @@ describe('Tabulated Editor test: ', function () {
isCheckedOut: false,
version: {id: '0.1', label: '0.1'},
viewableVersions: [{id: '0.1', label: '0.1'}],
+ itemPermission: {isCertified: false, isCollaborator: true, isDirty: false},
onSubmit: ()=>{},
onRevert: ()=>{}
}
};
- const view = TestUtils.renderIntoDocument(<TabulatedEditor {...props}><button>test</button></TabulatedEditor>);
+ const view = TestUtils.renderIntoDocument(<Provider store={store}><TabulatedEditor {...props}><button>test</button></TabulatedEditor></Provider>);
expect(view).toBeTruthy();
});
diff --git a/openecomp-ui/test/nfvo-components/modal/globalModal.test.js b/openecomp-ui/test/nfvo-components/modal/globalModal.test.js
index efe43b6c37..f27b1359f8 100644
--- a/openecomp-ui/test/nfvo-components/modal/globalModal.test.js
+++ b/openecomp-ui/test/nfvo-components/modal/globalModal.test.js
@@ -81,10 +81,10 @@ describe('Global Modal tests: ', function () {
it('checking component default render', ()=> {
- expect(window.document).toBeTruthy();
- let globalModalView = TestUtils.renderIntoDocument(
- <GlobalModalView show={true} type={typeEnum.WARNING} title={title} msg={msg} onDeclined={()=>{}} />
- );
+ expect(window.document).toBeTruthy();
+ let renderer = TestUtils.createRenderer();
+ renderer.render(<GlobalModalView show={true} type={typeEnum.WARNING} title={title} msg={msg} onDeclined={()=>{}} />);
+ let globalModalView = renderer.getRenderOutput();
expect(globalModalView).toBeTruthy();
});
diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js
index e14e9b76f5..f2db01f3f1 100644
--- a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js
+++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js
@@ -16,13 +16,14 @@
import React from 'react';
-import ReactDOMServer from 'react-dom/server';
+
import TestUtils from 'react-addons-test-utils';
-import {mount} from 'enzyme';
import VersionController from 'nfvo-components/panel/versionController/VersionController.jsx';
-import {actionsEnum, statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+import {actionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js';
import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
+import { Provider } from 'react-redux';
+import {storeCreator} from 'sdc-app/AppStore.js';
describe('versionController UI Component', () => {
let onSave, onClose, onVersionSwitching = onSave = onClose = () => {return Promise.resolve();};
@@ -30,42 +31,42 @@ describe('versionController UI Component', () => {
const isFormDataValid = true;
const viewableVersions = versionData.viewableVersions;
const version = versionData.version;
- const props = {onSave, onClose, isFormDataValid, viewableVersions, version, onVersionSwitching};
+ const itemPermission = {isCertified: false, isCollaborator: true, isDirty: false};
+ const props = {onSave, onClose, isFormDataValid, viewableVersions, version, onVersionSwitching, itemPermission};
+ const store = storeCreator();
it('function does exist', () => {
var renderer = TestUtils.createRenderer();
- renderer.render(<VersionController isCheckedOut={false} status={statusEnum.CHECK_OUT_STATUS} {...props} />);
+
+ renderer.render(<Provider store={store}><VersionController {...props} /></Provider>);
var renderedOutput = renderer.getRenderOutput();
expect(renderedOutput).toBeTruthy();
});
- it('validating checkin function', () => {
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...props} />);
- let cb = action => expect(action).toBe(actionsEnum.CHECK_IN);
- versionController.checkin(cb);
- });
-
- it('validating checkout function', () => {
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...props} />);
- let cb = action => expect(action).toBe(actionsEnum.CHECK_OUT);
- versionController.checkout(cb);
- });
-
it('validating submit function', () => {
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...props} />);
+ let provider = TestUtils.renderIntoDocument(<Provider store={store}>
+ <VersionController {...props} /></Provider>);
+ let versionController = TestUtils.findRenderedComponentWithType(
+ provider,
+ VersionController
+ );
let cb = action => expect(action).toBe(actionsEnum.SUBMIT);
versionController.submit(cb);
});
it('validating revert function', () => {
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...props} />);
- let cb = action => expect(action).toBe(actionsEnum.UNDO_CHECK_OUT);
- versionController.revertCheckout(cb);
+ let provider = TestUtils.renderIntoDocument(<Provider store={store}><VersionController {...props} /></Provider>);
+ let versionController = TestUtils.findRenderedComponentWithType(
+ provider,
+ VersionController
+ );
+ let cb = action => expect(action).toBe(actionsEnum.REVERT);
+ versionController.revert(cb);
});
it('does not show the save button when no onSave available', () => {
let noSaveProps = {...props, onSave: null };
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...noSaveProps} />);
+ let versionController = TestUtils.renderIntoDocument(<Provider store={store}><VersionController {...noSaveProps} /></Provider>);
let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-save-btn');
expect(elem).toBeTruthy();
expect(elem.length).toBe(0);
@@ -73,7 +74,7 @@ describe('versionController UI Component', () => {
it('does not show the submit button when no callVCAction available', () => {
let callVCActionProps = {...props, callVCAction: null};
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...callVCActionProps} />);
+ let versionController = TestUtils.renderIntoDocument(<Provider store={store}><VersionController {...callVCActionProps} /></Provider>);
let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-submit-btn');
expect(elem).toBeTruthy();
expect(elem.length).toBe(0);
@@ -81,72 +82,45 @@ describe('versionController UI Component', () => {
it('does not show the revert button when no callVCAction available', () => {
let callVCActionProps = {...props, callVCAction: null};
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...callVCActionProps} />);
+ let versionController = TestUtils.renderIntoDocument(<Provider store={store}><VersionController {...callVCActionProps} /></Provider>);
let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-revert-btn');
expect(elem).toBeTruthy();
expect(elem.length).toBe(0);
});
it('Shows the save button when onSave available', () => {
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...props} />);
+ let versionController = TestUtils.renderIntoDocument(<Provider store={store}><VersionController {...props} /></Provider>);
let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-save-btn');
expect(elem).toBeTruthy();
expect(elem.length).toBe(1);
});
- it('Shows the submit button when callVCAction available', () => {
- let callVCActionProps = { ...props, callVCAction: function(){} };
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...callVCActionProps} />);
+ it('Shows the submit button when callVCAction available and user is owner', () => {
+ const permissions = {owner: {userId: '111'}},
+ userInfo = {userId: '111'};
+ let callVCActionProps = { ...props, callVCAction: function(){}, permissions, userInfo};
+ let versionController = TestUtils.renderIntoDocument(<Provider store={store}><VersionController {...callVCActionProps} /></Provider>);
let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-submit-btn');
expect(elem).toBeTruthy();
expect(elem.length).toBe(1);
});
- it('Shows the revert button when callVCAction available', () => {
- let callVCActionProps = { ...props, callVCAction: function(){} };
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...callVCActionProps} />);
- let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-revert-btn');
- expect(elem).toBeTruthy();
- expect(elem.length).toBe(1);
- });
-
- it('Shows the checkin button', () => {
- let callVCActionProps = { ...props, callVCAction: function(){} };
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...callVCActionProps} />);
- let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-checkout-btn');
+ it('Doesn\'t show the submit button when user is not owner', () => {
+ const permissions = {owner: {userId: '111'}},
+ userInfo = {userId: '222'};
+ let callVCActionProps = { ...props, callVCAction: function(){}, permissions, userInfo};
+ let versionController = TestUtils.renderIntoDocument(<Provider store={store}><VersionController {...callVCActionProps} /></Provider>);
+ let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-submit-btn');
expect(elem).toBeTruthy();
- expect(elem.length).toBe(1);
+ expect(elem.length).toBe(0);
});
- it('Shows the checkout button', () => {
+ it('Shows the revert button when callVCAction available', () => {
let callVCActionProps = { ...props, callVCAction: function(){} };
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...callVCActionProps} />);
- let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-checkout-btn');
- expect(elem).toBeTruthy();
- expect(elem.length).toBe(1);
-
- });
-
- it('Doesn\'t show the checkin button for prev version', () => {
- let callVCActionProps = { ...props, version: '1.0', callVCAction: function(){} };
- let versionController = mount(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...callVCActionProps} />);
- let elem = versionController.find('[data-test-id="vc-checkout-btn"]');
-
- expect(elem).toBeTruthy();
- expect(elem.length).toEqual(1);
- expect(elem.find('.svg-icon').length).toEqual(1);
- expect(elem.find('.svg-icon').hasClass('disabled')).toBe(true);
- });
-
- it('Doesn\'t show the checkout button', () => {
- let callVCActionProps = { ...props, version: '1.0', callVCAction: function(){} };
- let versionController = mount(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...callVCActionProps} />);
- let elem = versionController.find('[data-test-id="vc-checkout-btn"]');
+ let versionController = TestUtils.renderIntoDocument(<Provider store={store}><VersionController {...callVCActionProps} /></Provider>);
+ let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-revert-btn');
expect(elem).toBeTruthy();
expect(elem.length).toBe(1);
- expect(elem.find('.svg-icon').length).toEqual(1);
- expect(elem.find('.svg-icon').hasClass('disabled')).toBe(true);
-
});
});
diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js
deleted file mode 100644
index d654e16ddf..0000000000
--- a/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js
+++ /dev/null
@@ -1,128 +0,0 @@
-/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- *
- * 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.
- */
-
-
-import Configuration from 'sdc-app/config/Configuration.js';
-import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
-import {statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
-import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
-
-const status = 'testStatus';
-const {lockingUser: currentUser, viewableVersions: defaultVersions} = VersionControllerUtilsFactory.build();
-
-describe('versionController UI Component', () => {
-
- it('function does exist', () => {
- expect(VersionControllerUtils).toBeTruthy();
- });
-
- it('validating getCheckOutStatusKindByUserID - without "UserID"', () => {
- var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status);
- expect(result.status).toBe(status);
- expect(result.isCheckedOut).toBe(false);
- });
-
- it('validating getCheckOutStatusKindByUserID - without "UserID" with locking user', () => {
- var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status, 'locking user');
- expect(result.status).toBe(statusEnum.LOCK_STATUS);
- expect(result.isCheckedOut).toBe(false);
- });
-
- it('validating getCheckOutStatusKindByUserID - with "UserID" with configuration set', () => {
- const Uid = 'ecomp';
-
- Configuration.set('UserID', Uid);
- var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status, Uid);
- Configuration.set('UserID', undefined);
- expect(result.status).toBe(status);
- expect(result.isCheckedOut).toBe(true);
- });
-
-
-
- it('validating isCheckedOutByCurrentUser - when resource is not checked out', () => {
- const resource = VersionControllerUtilsFactory.build({status: statusEnum.SUBMIT_STATUS});
-
- Configuration.set('UserID', currentUser);
- const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource);
- Configuration.set('UserID', undefined);
-
- expect(result).toBe(false);
- });
-
- it('validating isCheckedOutByCurrentUser - when resource is checked out', () => {
- const resource = VersionControllerUtilsFactory.build();
-
- Configuration.set('UserID', currentUser);
- const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource);
- Configuration.set('UserID', undefined);
-
- expect(result).toBe(true);
- });
-
- it('validating isCheckedOutByCurrentUser - when resource is checked out by another user', () => {
- const resource = VersionControllerUtilsFactory.build({lockingUser: 'another'});
-
- Configuration.set('UserID', currentUser);
- const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource);
- Configuration.set('UserID', undefined);
-
- expect(result).toBe(false);
- });
-
-
-
- it('validating isReadOnly - when resource is not checked out', () => {
- const resource = VersionControllerUtilsFactory.build({status: statusEnum.SUBMIT_STATUS});
-
- Configuration.set('UserID', currentUser);
- const result = VersionControllerUtils.isReadOnly(resource);
- Configuration.set('UserID', undefined);
-
- expect(result).toBe(true);
- });
-
- it('validating isReadOnly - when resource is checked out', () => {
- const resource = VersionControllerUtilsFactory.build();
-
- Configuration.set('UserID', currentUser);
- const result = VersionControllerUtils.isReadOnly(resource);
- Configuration.set('UserID', undefined);
-
- expect(result).toBe(false);
- });
-
- it('validating isReadOnly - when version of resource is not latest', () => {
-
- const resource = VersionControllerUtilsFactory.build({version: defaultVersions[defaultVersions.length - 2]});
-
- Configuration.set('UserID', currentUser);
- const result = VersionControllerUtils.isReadOnly(resource);
- Configuration.set('UserID', undefined);
-
- expect(result).toBe(true);
- });
-
- it('validating isReadOnly - when resource is checked out by another user', () => {
- const resource = VersionControllerUtilsFactory.build({lockingUser: 'another'});
-
- Configuration.set('UserID', currentUser);
- const result = VersionControllerUtils.isReadOnly(resource);
- Configuration.set('UserID', undefined);
-
- expect(result).toBe(true);
- });
-});
diff --git a/openecomp-ui/test/nfvo-components/tree/tree.test.js b/openecomp-ui/test/nfvo-components/tree/tree.test.js
new file mode 100644
index 0000000000..95d0ae7f87
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/tree/tree.test.js
@@ -0,0 +1,31 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * 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.
+ */
+import Tree from 'nfvo-components/tree/Tree.jsx';
+
+describe('Tree Module Tests', function () {
+
+ it('Tree view should exist', () => {
+ expect(Tree).toBeTruthy();
+ });
+
+ it('should render Tree and call onNodeClick', done => {
+ const tree = [{id: '123', name: '', parent: ''}];
+ let treeView = new Tree({nodes: tree, onNodeClick: () => done()});
+ expect(treeView).toBeTruthy();
+ treeView.onNodeClick(tree[0]);
+ });
+
+});