2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import {expect} from 'chai';
22 import deepFreeze from 'deep-freeze';
23 import mockRest from 'test-utils/MockRest.js';
24 import {cloneAndSet} from 'test-utils/Util.js';
25 import {storeCreator} from 'sdc-app/AppStore.js';
26 import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js';
28 const softwareProductId = '123';
29 const vspComponentId = '321';
31 describe('Software Product Components Module Tests', function () {
32 it('Get Software Products Components List', () => {
33 const store = storeCreator();
34 deepFreeze(store.getState());
36 const softwareProductComponentsList = [
38 name: 'com.d2.resource.vfc.nodes.heat.sm_server',
39 displayName: 'sm_server',
41 id: 'EBADF561B7FA4A788075E1840D0B5971'
44 name: 'com.d2.resource.vfc.nodes.heat.pd_server',
45 displayName: 'pd_server',
47 id: '2F47447D22DB4C53B020CA1E66201EF2'
51 deepFreeze(softwareProductComponentsList);
53 deepFreeze(store.getState());
55 const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentsList', softwareProductComponentsList);
57 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
58 expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components`);
59 expect(data).to.deep.equal(undefined);
60 expect(options).to.equal(undefined);
61 return {results: softwareProductComponentsList};
64 return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(store.dispatch, {softwareProductId}).then(() => {
65 expect(store.getState()).to.deep.equal(expectedStore);
69 it('Update SoftwareProduct Component Questionnaire', () => {
70 const store = storeCreator();
72 const qdataUpdated = {
75 containerFeatureDescription: 'aaaUpdated',
76 drivers: 'bbbUpdated',
77 hypervisor: 'cccUpdated'
82 const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', qdataUpdated);
83 deepFreeze(expectedStore);
86 mockRest.addHandler('save', ({options, data, baseUrl}) => {
87 expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
88 expect(data).to.deep.equal(qdataUpdated);
89 expect(options).to.equal(undefined);
90 return {returnCode: 'OK'};
93 return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId, qdata: qdataUpdated}).then(() => {
94 //TODO think should we add here something or not