diff options
author | brunomilitzer <bruno.militzer@est.tech> | 2022-02-11 09:15:36 +0000 |
---|---|---|
committer | brunomilitzer <bruno.militzer@est.tech> | 2022-02-11 15:52:56 +0000 |
commit | fc2177dfac650f364743277abd4258f4b7b4557a (patch) | |
tree | bfce0e4811cbff6877c551556f75986cc5c62318 /gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js | |
parent | 5ca5cc1e2607518d1fd2c05421a6e6b8c9cd12ea (diff) |
Added Jest Tests on ViewAllPolicies and PolicyDeploymentEditor
Issue-ID: POLICY-3916
Change-Id: I81e34903bf1e8d2d059b755d58eea7738b600829
Signed-off-by: brunomilitzer <bruno.militzer@est.tech>
Diffstat (limited to 'gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js')
-rw-r--r-- | gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js b/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js index d4a3fd9..c2ce731 100644 --- a/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js +++ b/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js @@ -23,7 +23,6 @@ import ViewAllPolicies from "./ViewAllPolicies"; import fs from "fs"; import PolicyToscaService from "../../../api/PolicyToscaService"; import PolicyService from "../../../api/PolicyService"; -import CreateLoopModal from "../Loop/CreateLoopModal"; import toJson from "enzyme-to-json"; describe('Verify ViewAllPolicies', () => { @@ -36,6 +35,12 @@ describe('Verify ViewAllPolicies', () => { flag: 'r' }); + const toscaPolicyModelsArray = JSON.parse(toscaPolicyModels); + + const toscaPoliciesListArray = JSON.parse(toscaPoliciesList); + + const logSpy = jest.spyOn(console, 'log'); + it("renders correctly", () => { const component = shallow(<ViewAllPolicies />); expect(toJson(component)).toMatchSnapshot(); @@ -127,15 +132,33 @@ describe('Verify ViewAllPolicies', () => { }); const event = { target: {value: 'event'}} - const component = shallow(<CreateLoopModal/>); + const renderPoliciesTab = jest.spyOn(ViewAllPolicies.prototype, 'renderPoliciesTab'); + + const component = shallow(<ViewAllPolicies />); component.setState({showSuccessAlert: true}); component.setState({showMessage: 'Policy successfully Deleted'}); + component.setState({policiesListDataFiltered: toscaPolicyModelsArray}); - component.find('input').simulate('click', event, rowData); component.update(); + const instance = component.instance(); + + instance.handleDeletePolicy(event, rowData); + + expect(renderPoliciesTab).toHaveBeenCalledTimes(4); expect(component.state('showSuccessAlert')).toEqual(true); expect(component.state('showMessage')).toEqual('Policy successfully Deleted'); }); + + it('Test generateAdditionalPolicyColumns policiesData', async () => { + const component = shallow(<ViewAllPolicies />); + + const instance = component.instance(); + instance.generateAdditionalPolicyColumns(toscaPoliciesListArray.policies); + + component.update(); + + expect(logSpy).toHaveBeenCalledWith('generateAdditionalPolicyColumns called'); + }); }); |