From f8ec2dcdcec8a686d3e58d82a99aa097df2f0c41 Mon Sep 17 00:00:00 2001 From: brunomilitzer Date: Thu, 27 Jan 2022 17:51:58 +0000 Subject: Added Menu and Loop Jest Tests Issue-ID: POLICY-3876 Change-Id: I5f4d80aefdff8b837a40742b66727b888e985b86 Signed-off-by: brunomilitzer --- .../dialogs/Loop/ModifyLoopModal.test.js | 32 +++++++++++++++------- 1 file changed, 22 insertions(+), 10 deletions(-) (limited to 'gui-clamp/ui-react/src/components/dialogs/Loop/ModifyLoopModal.test.js') diff --git a/gui-clamp/ui-react/src/components/dialogs/Loop/ModifyLoopModal.test.js b/gui-clamp/ui-react/src/components/dialogs/Loop/ModifyLoopModal.test.js index 79267af..ef57998 100644 --- a/gui-clamp/ui-react/src/components/dialogs/Loop/ModifyLoopModal.test.js +++ b/gui-clamp/ui-react/src/components/dialogs/Loop/ModifyLoopModal.test.js @@ -2,8 +2,8 @@ * ============LICENSE_START======================================================= * ONAP CLAMP * ================================================================================ - * Copyright (C) 2020 AT&T Intellectual Property. All rights - * reserved. + * Copyright (C) 2020 AT&T Intellectual Property. All rights reserved. + * Modifications Copyright (C) 2022 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -28,15 +28,18 @@ import LoopService from '../../../api/LoopService'; import PolicyToscaService from '../../../api/PolicyToscaService'; describe('Verify ModifyLoopModal', () => { + const toscaPolicyModels = [{ + "policyModelType": "test", + "policyAcronym": "test", + "version": "1.0.0", + "updatedBy": "", + "updatedDate": "" + }]; + const selectedPolicyModels = []; + beforeEach(() => { PolicyToscaService.getToscaPolicyModels = jest.fn().mockImplementation(() => { - return Promise.resolve([{ - "policyModelType": "test", - "policyAcronym": "test", - "version": "1.0.0", - "updatedBy": "", - "updatedDate": "" - }]); + return Promise.resolve(toscaPolicyModels); }); PolicyToscaService.getToscaPolicyModelYaml = jest.fn().mockImplementation(() => { return Promise.resolve("OK"); @@ -62,7 +65,6 @@ describe('Verify ModifyLoopModal', () => { } }); const historyMock = { push: jest.fn() }; - const flushPromises = () => new Promise(setImmediate); it('Test handleClose', () => { const handleClose = jest.spyOn(ModifyLoopModal.prototype, 'handleClose'); @@ -106,4 +108,14 @@ describe('Verify ModifyLoopModal', () => { instance.handleYamlContent(event); expect(component.state('content')).toEqual("testValue"); }); + + it('Test initializeToscaPolicyModelsInfo', () => { + const component = mount() + component.setState({ + toscaPolicyModelsData: toscaPolicyModels, + selectedPolicyModelsData: selectedPolicyModels + }); + expect(component.state('toscaPolicyModelsData')).toEqual(toscaPolicyModels); + expect(component.state('selectedPolicyModelsData')).toEqual(selectedPolicyModels); + }); }); -- cgit 1.2.3-korg