summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/softwareProduct/components/storage
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test/softwareProduct/components/storage')
-rw-r--r--openecomp-ui/test/softwareProduct/components/storage/test.js85
1 files changed, 30 insertions, 55 deletions
diff --git a/openecomp-ui/test/softwareProduct/components/storage/test.js b/openecomp-ui/test/softwareProduct/components/storage/test.js
index 87cad368be..138c4da7d6 100644
--- a/openecomp-ui/test/softwareProduct/components/storage/test.js
+++ b/openecomp-ui/test/softwareProduct/components/storage/test.js
@@ -1,24 +1,19 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* 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
- *
+ *
+ * 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=========================================================
+ * 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 expect from 'expect';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
import {cloneAndSet} from 'test-utils/Util.js';
@@ -26,14 +21,18 @@ import {storeCreator} from 'sdc-app/AppStore.js';
import Configuration from 'sdc-app/config/Configuration.js';
import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js';
+import {default as VSPComponentsStorageFactory, VSPComponentsStorageDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsStorageFactory.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+
const softwareProductId = '123';
const vspComponentId = '111';
+const version = VersionControllerUtilsFactory.build().version;
describe('Software Product Components Storage Module Tests', function () {
let restPrefix = '';
- before(function() {
+ beforeAll(function() {
restPrefix = Configuration.get('restPrefix');
deepFreeze(restPrefix);
});
@@ -42,28 +41,32 @@ describe('Software Product Components Storage Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
+ const storage = VSPComponentsStorageFactory.build();
+ const dataMap = VSPComponentsStorageDataMapFactory.build();
+
const softwareProductComponentStorage = {
- data: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}),
- schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}})
+ data: JSON.stringify(storage),
+ schema: JSON.stringify(storage)
};
deepFreeze(softwareProductComponentStorage);
const softwareProductComponentStorageData = {
- qdata: JSON.parse(softwareProductComponentStorage.data),
- qschema: JSON.parse(softwareProductComponentStorage.schema)
+ qdata: storage,
+ dataMap: dataMap,
+ qgenericFieldInfo: {}
};
deepFreeze(softwareProductComponentStorageData);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentStorageData);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`);
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
return softwareProductComponentStorage;
});
- return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => {
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => {
expect(store.getState()).toEqual(expectedStore);
});
});
@@ -72,61 +75,33 @@ describe('Software Product Components Storage Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
+ const storage = VSPComponentsStorageFactory.build();
+
const softwareProductComponentQuestionnaire = {
data: null,
- schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}})
+ schema: JSON.stringify(storage)
};
deepFreeze(softwareProductComponentQuestionnaire);
const softwareProductComponentQuestionnaireData = {
qdata: {},
- qschema: JSON.parse(softwareProductComponentQuestionnaire.schema)
+ dataMap: {},
+ qgenericFieldInfo: {}
};
deepFreeze(softwareProductComponentQuestionnaireData);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentQuestionnaireData);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`);
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
return softwareProductComponentQuestionnaire;
});
- return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => {
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => {
expect(store.getState()).toEqual(expectedStore);
});
});
- it('Update Software Products Components Storage', () => {
- const store = storeCreator({
- softwareProduct: {
- softwareProductComponents: {
- componentEditor: {
- qdata: {
- backupType: 'OnSite',
- backupStorageSize: 30
- },
- qschema: {
- type: 'object',
- properties: {
- backupType: {type: 'string'},
- backupStorageSize: {type: 'number'}
- }
- }
- }
- }
- }
- });
- deepFreeze(store);
-
- const data = {backupType: 'OffSite', backupStorageSize: 30};
- deepFreeze(data);
-
- const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', data);
-
- SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(store.dispatch, {data});
-
- expect(store.getState()).toEqual(expectedStore);
- });
});