aboutsummaryrefslogtreecommitdiffstats
path: root/gui-clamp/ui-react/src/components/dialogs/Policy/ViewAllPolicies.test.js
diff options
context:
space:
mode:
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.js29
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');
+ });
});