summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js
diff options
context:
space:
mode:
authorVodafone <onap@vodafone.com>2019-04-05 15:49:06 +0530
committerOren Kleks <orenkle@amdocs.com>2019-04-10 06:41:37 +0000
commit18750938b1513ee32d4d68f0871ec90efdf3ddfd (patch)
treefae174b2b4d42cf5fa60312c78ced935c318cd25 /openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js
parentef0e8be1453e3959b38c9832e3e729e4e86a9e04 (diff)
VSP Compliance Check for Compute Flavor
Change-Id: I04768a20413393026606a3f5b200e959e37c1410 Issue-ID: SDC-2051 Co-authored-by: rahul.ghugikar@vodafone.com, soumyarup.paul@vodafone.com Signed-off-by: Vodafone <onap@vodafone.com>
Diffstat (limited to 'openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js')
-rw-r--r--openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js216
1 files changed, 163 insertions, 53 deletions
diff --git a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js
index ee6ba90cd5..0a8f640426 100644
--- a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js
+++ b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js
@@ -26,83 +26,193 @@ import { VSPComplianceCheckedFactory } from 'test-utils/factories/softwareProduc
import { VSPCertificationCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
+import { VSPTestsRequestFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
+import { VSPGeneralInfoFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js';
+import { VSPTestResultsSuccessFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js';
+import { mapActionsToProps } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js';
describe('Software Product Validation Action Helper Tests', function() {
- it('Software Products Validation Action Helper : Dsspatch', () => {
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const vspChecksList = VSPChecksFactory.build();
- const vspTestsMap = VSPTestsMapFactory.build();
- const certificationChecked = VSPCertificationCheckedFactory.build();
- const complianceChecked = VSPComplianceCheckedFactory.build();
- const activeTab = { activeTab: tabsMapping.INPUTS };
- const errorMessage = { msg: 'Test Error Message' };
-
- deepFreeze(vspChecksList);
- deepFreeze(vspTestsMap);
- deepFreeze(certificationChecked);
- deepFreeze(complianceChecked);
- deepFreeze(activeTab);
+ const store = storeCreator();
+ deepFreeze(store.getState());
+ const vspChecksList = VSPChecksFactory.build();
+ const vspTestsMap = VSPTestsMapFactory.build();
+ const certificationChecked = VSPCertificationCheckedFactory.build();
+ const complianceChecked = VSPComplianceCheckedFactory.build();
+ const activeTab = { activeTab: tabsMapping.INPUTS };
+ const errorMessage = { msg: 'Test Error Message' };
+ const testsRequest = VSPTestsRequestFactory.build();
+ const generalInfo = VSPGeneralInfoFactory.build();
+ const isValidationDisabled = false;
+ const vspTestResults = VSPTestResultsSuccessFactory.build();
+ let restPrefix = Configuration.get('restPrefix');
+ let onClose = () => {};
+
+ const modal = {
+ type: 'error',
+ title: 'Error',
+ modalComponentName: 'Error',
+ modalComponentProps: {
+ onClose: onClose
+ },
+ msg: {
+ msg: 'Test Error Message'
+ },
+ cancelButtonText: 'OK'
+ };
+ // deepFreeze(vspTestsMap.vspTestsMap);
+ // deepFreeze(certificationChecked.certificationChecked);
+ // deepFreeze(complianceChecked.complianceChecked);
+ // deepFreeze(activeTab);
+ // deepFreeze(testsRequest);
+ // deepFreeze(generalInfo.generalInfo);
+ // deepFreeze(isVspValidationDisabled);
+
+ it('Software Products Validation Action Helper : fetch vsp', () => {
let expectedStore = cloneAndSet(
store.getState(),
'softwareProduct.softwareProductValidation.vspChecks',
vspChecksList
);
- expectedStore = cloneAndSet(
- store.getState(),
- 'softwareProduct.softwareProductValidation.vspTestsMap',
- vspTestsMap
- );
- expectedStore = cloneAndSet(
+ mockRest.addHandler('fetch', ({ baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `${restPrefix}/v1.0/externaltesting/testcasetree`
+ );
+ return vspChecksList;
+ });
+ return SoftwareProductValidationActionHelper.fetchVspChecks(
+ store.dispatch
+ )
+ .then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ })
+ .catch(() => {
+ console.log('Fetch VSP returned Error');
+ });
+ });
+
+ // it('Software Products Validation Action Helper : post test', () => {
+ // mockRest.addHandler('post', ({ options, data, baseUrl }) => {
+ // expect(baseUrl).toEqual(
+ // `${restPrefix}/v1.0/externaltesting/executions`
+ // );
+ // //expect(data).toEqual(testsRequest);
+ // expect(options).toEqual(undefined);
+ // return { vspTestResults: vspTestResults };
+ // });
+ // const version = {
+ // id: 12345,
+ // name: 1
+ // };
+ // const softwareProductId = '1234';
+ // const status = 'draft';
+ // mapActionsToProps(store.dispatch).onTestSubmit(
+ // softwareProductId,
+ // version,
+ // status,
+ // testsRequest
+ // );
+ // });
+
+ it('Software Products Validation Action Helper : setCertificationChecked', () => {
+ let expectedStore = cloneAndSet(
store.getState(),
'softwareProduct.softwareProductValidation.certificationChecked',
- certificationChecked
+ certificationChecked.certificationChecked
);
- expectedStore = cloneAndSet(
+ mapActionsToProps(store.dispatch).setCertificationChecked({
+ checked: certificationChecked.certificationChecked
+ });
+ expect(store.getState()).toEqual(expectedStore);
+ });
+
+ it('Software Products Validation Action Helper : onErrorThrown', () => {
+ let expectedStore = cloneAndSet(store.getState(), 'modal', modal);
+ mapActionsToProps(store.dispatch).onErrorThrown(errorMessage);
+ expect(JSON.stringify(store.getState())).toEqual(
+ JSON.stringify(expectedStore)
+ );
+ });
+
+ it('Software Products Validation Action Helper : setComplianceChecked', () => {
+ let expectedStore = cloneAndSet(
store.getState(),
'softwareProduct.softwareProductValidation.complianceChecked',
- complianceChecked
+ complianceChecked.complianceChecked
);
- expectedStore = cloneAndSet(
+ mapActionsToProps(store.dispatch).setComplianceChecked({
+ checked: complianceChecked.complianceChecked
+ });
+ expect(store.getState()).toEqual(expectedStore);
+ });
+
+ it('Software Products Validation Action Helper : setActiveTab', () => {
+ let expectedStore = cloneAndSet(
store.getState(),
'softwareProduct.softwareProductValidation.activeTab',
- activeTab
+ activeTab.activeTab
);
- let restPrefix = Configuration.get('restPrefix');
+ mapActionsToProps(store.dispatch).setActiveTab(activeTab);
+ expect(store.getState()).toEqual(expectedStore);
+ });
- mockRest.addHandler('fetch', ({ options, data, baseUrl }) => {
- expect(baseUrl).toEqual(`${restPrefix}/v1.0/externaltesting`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return { vspChecks: vspChecksList };
- });
+ it('Software Products Validation Action Helper : setGeneralInfo', () => {
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'softwareProduct.softwareProductValidation.generalInfo',
+ generalInfo.generalInfo
+ );
+ mapActionsToProps(store.dispatch).setGeneralInfo(
+ generalInfo.generalInfo
+ );
+ expect(store.getState()).toEqual(expectedStore);
+ });
- SoftwareProductValidationActionHelper.setVspTestsMap(store.dispatch, {
- vspTestsMap
- });
- SoftwareProductValidationActionHelper.setComplianceChecked(
- store.dispatch,
- { complianceChecked }
+ it('Software Products Validation Action Helper : setIsVspValidationDisabled', () => {
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'softwareProduct.softwareProductValidation.isValidationDisabled',
+ isValidationDisabled
);
- SoftwareProductValidationActionHelper.setCertificationChecked(
+ SoftwareProductValidationActionHelper.setIsVspValidationDisabled(
store.dispatch,
- { certificationChecked }
+ {
+ isValidationDisabled
+ }
);
+ expect(store.getState()).toEqual(expectedStore);
+ });
- SoftwareProductValidationActionHelper.setActiveTab(store.dispatch, {
- activeTab
- });
+ it('Software Products Validation Action Helper : setTestsRequest', () => {
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'softwareProduct.softwareProductValidation.testsRequest',
+ testsRequest.testsRequest
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'softwareProduct.softwareProductValidation.generalInfo',
+ generalInfo.generalInfo
+ );
- SoftwareProductValidationActionHelper.onErrorThrown(store.dispatch, {
- errorMessage
- });
+ mapActionsToProps(store.dispatch).setTestsRequest(
+ testsRequest.testsRequest,
+ generalInfo.generalInfo
+ );
+ expect(store.getState()).toEqual(expectedStore);
+ });
- SoftwareProductValidationActionHelper.fetchVspChecks(store.dispatch)
- .then(() => {
- expect(store.getState()).toEqual(expectedStore);
- })
- .catch(() => {});
+ it('Software Products Validation Action Helper : setVspTestsMap', () => {
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'softwareProduct.softwareProductValidation.vspTestsMap',
+ vspTestsMap.vspTestsMap
+ );
+ SoftwareProductValidationActionHelper.setVspTestsMap(
+ store.dispatch,
+ vspTestsMap.vspTestsMap
+ );
+
+ expect(store.getState()).toEqual(expectedStore);
});
});