summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/softwareProduct/components/network
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test/softwareProduct/components/network')
-rw-r--r--openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js5
-rw-r--r--openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js118
2 files changed, 66 insertions, 57 deletions
diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js
index 094b95a091..78d88b008a 100644
--- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js
+++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js
@@ -23,6 +23,7 @@ import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwarePro
import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js';
import {VSPComponentsNicFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNicFactoryQGenericFieldInfo,
VSPComponentsNicFactoryGenericFieldInfo, VSPComponentsNetworkDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
+import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
describe('Software Product Component Network NIC Editor and View Classes', () => {
it('mapStateToProps mapper exists', () => {
@@ -34,8 +35,8 @@ describe('Software Product Component Network NIC Editor and View Classes', () =>
const currentSoftwareProduct = VSPEditorFactory.build();
-
var obj = {
+ currentScreen: CurrentScreenFactory.build(),
softwareProduct: SoftwareProductFactory.build({
softwareProductEditor: {
data: currentSoftwareProduct
@@ -55,12 +56,14 @@ describe('Software Product Component Network NIC Editor and View Classes', () =>
};
var results = mapStateToProps(obj);
+ expect(results.isReadOnlyMode).toBe(false);
expect(results.currentSoftwareProduct).toBeTruthy();
expect(results.qdata).toBeTruthy();
expect(results.dataMap).toBeTruthy();
expect(results.genericFieldInfo).toBeTruthy();
expect(results.qgenericFieldInfo).toBeTruthy();
expect(results.data).toBeTruthy();
+
});
diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js
index b6050265a6..11a0ca787f 100644
--- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js
+++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js
@@ -19,15 +19,20 @@ import {cloneAndSet} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import SoftwareProductComponentsNetworkActionHelper from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js';
-import {VSPComponentsNicPostFactory, VSPComponentsNicFactory, VSPComponentsNetworkFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNetworkDataMapFactory, VSPComponentsNicFactoryGenericFieldInfo} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
-import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+import {VSPComponentsNicFactory,
+ VSPComponentsNicPostFactory,
+ VSPComponentsNetworkFactory,
+ VSPComponentsNetworkQDataFactory,
+ VSPComponentsNetworkDataMapFactory,
+ VSPComponentsNicFactoryGenericFieldInfo} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
+import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js';
import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js';
const softwareProductId = '123';
const componentId = '321';
const nicId = '111';
-const version = VersionControllerUtilsFactory.build().version;
+const version = VersionFactory.build();
describe('Software Product Components Network Action Helper Tests', function () {
@@ -55,60 +60,62 @@ describe('Software Product Components Network Action Helper Tests', function ()
});
});
+
it('Add NIC', () => {
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const NICPostRequest = VSPComponentsNicPostFactory.build();
-
- const expectedNIC = VSPComponentsNicFactory.build({...NICPostRequest, id: nicId});
-
- mockRest.addHandler('post', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`);
- expect(data).toEqual(NICPostRequest);
- expect(options).toEqual(undefined);
- return {
- nicId
- };
- });
-
- mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: [expectedNIC]};
- });
-
- mockRest.addHandler('destroy', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {};
- });
-
- mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: []};
- });
-
- const network = VSPComponentsNetworkFactory.build({
- nicList: [expectedNIC]
- });
-
- const networkAfterDelete = VSPComponentsNetworkFactory.build();
-
- let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
-
- return SoftwareProductComponentsNetworkActionHelper.createNIC(store.dispatch, {nic: NICPostRequest, softwareProductId, componentId, version}).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- return SoftwareProductComponentsNetworkActionHelper.deleteNIC(store.dispatch, {softwareProductId, componentId, nicId, version});
- }).then(() => {
- let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', networkAfterDelete);
- expect(store.getState()).toEqual(expectedStore);
- });
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const NICPostRequest = VSPComponentsNicPostFactory.build();
+
+ const expectedNIC = VSPComponentsNicFactory.build({...NICPostRequest, id: nicId});
+
+ mockRest.addHandler('post', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`);
+ expect(data).toEqual(NICPostRequest);
+ expect(options).toEqual(undefined);
+ return {
+ nicId
+ };
+ });
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: [expectedNIC]};
+ });
+
+ mockRest.addHandler('destroy', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {};
});
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+ const network = VSPComponentsNetworkFactory.build({
+ nicList: [expectedNIC]
+ });
+
+ const networkAfterDelete = VSPComponentsNetworkFactory.build();
+
+ let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
+
+ return SoftwareProductComponentsNetworkActionHelper.createNIC(store.dispatch, {nic: NICPostRequest, softwareProductId, componentId, version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ return SoftwareProductComponentsNetworkActionHelper.deleteNIC(store.dispatch, {softwareProductId, componentId, nicId, version});
+ }).then(() => {
+ let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', networkAfterDelete);
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
it('open NICE editor', () => {
const store = storeCreator();
@@ -172,7 +179,6 @@ describe('Software Product Components Network Action Helper Tests', function ()
});
});
-
it('load NIC Questionnaire', () => {
mockRest.resetQueue();
const store = storeCreator();