2 * Copyright © 2019 Vodafone Group
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 import deepFreeze from 'deep-freeze';
17 import mockRest from 'test-utils/MockRest.js';
18 import { cloneAndSet } from 'test-utils/Util.js';
19 import { storeCreator } from 'sdc-app/AppStore.js';
20 import SoftwareProductValidationActionHelper from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js';
21 import { tabsMapping } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationConstants.js';
23 import Configuration from 'sdc-app/config/Configuration.js';
25 import { VSPComplianceCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
26 import { VSPCertificationCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
27 import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
28 import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
30 describe('Software Product Validation Action Helper Tests', function() {
31 it('Software Products Validation Action Helper : Dsspatch', () => {
32 const store = storeCreator();
33 deepFreeze(store.getState());
35 const vspChecksList = VSPChecksFactory.build();
36 const vspTestsMap = VSPTestsMapFactory.build();
37 const certificationChecked = VSPCertificationCheckedFactory.build();
38 const complianceChecked = VSPComplianceCheckedFactory.build();
39 const activeTab = { activeTab: tabsMapping.INPUTS };
40 const errorMessage = { msg: 'Test Error Message' };
42 deepFreeze(vspChecksList);
43 deepFreeze(vspTestsMap);
44 deepFreeze(certificationChecked);
45 deepFreeze(complianceChecked);
46 deepFreeze(activeTab);
48 let expectedStore = cloneAndSet(
50 'softwareProduct.softwareProductValidation.vspChecks',
53 expectedStore = cloneAndSet(
55 'softwareProduct.softwareProductValidation.vspTestsMap',
58 expectedStore = cloneAndSet(
60 'softwareProduct.softwareProductValidation.certificationChecked',
63 expectedStore = cloneAndSet(
65 'softwareProduct.softwareProductValidation.complianceChecked',
68 expectedStore = cloneAndSet(
70 'softwareProduct.softwareProductValidation.activeTab',
73 let restPrefix = Configuration.get('restPrefix');
75 mockRest.addHandler('fetch', ({ options, data, baseUrl }) => {
76 expect(baseUrl).toEqual(`${restPrefix}/v1.0/externaltesting`);
77 expect(data).toEqual(undefined);
78 expect(options).toEqual(undefined);
79 return { vspChecks: vspChecksList };
82 SoftwareProductValidationActionHelper.setVspTestsMap(store.dispatch, {
85 SoftwareProductValidationActionHelper.setComplianceChecked(
89 SoftwareProductValidationActionHelper.setCertificationChecked(
91 { certificationChecked }
94 SoftwareProductValidationActionHelper.setActiveTab(store.dispatch, {
98 SoftwareProductValidationActionHelper.onErrorThrown(store.dispatch, {
102 SoftwareProductValidationActionHelper.fetchVspChecks(store.dispatch)
104 expect(store.getState()).toEqual(expectedStore);