aboutsummaryrefslogtreecommitdiffstats
path: root/gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.test.js
diff options
context:
space:
mode:
authorbrunomilitzer <bruno.militzer@est.tech>2021-10-28 15:34:43 +0100
committerbrunomilitzer <bruno.militzer@est.tech>2021-10-28 15:34:53 +0100
commit53b46adf3359b37cd83fea036c1b87f8b55683db (patch)
tree97204bb7ea1eac046f5becd62197c75084b68554 /gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.test.js
parenta8140d3db5264bbc9dfd513c51d78951b42c6c37 (diff)
Added JEST Unit Tests for Monitoring Functionality
Created Unit Tests to cover monitoring functionality Issue-ID: POLICY-3561 Change-Id: I48035f3960447c66d29005d5eba2e8332c55b591 Signed-off-by: brunomilitzer <bruno.militzer@est.tech>
Diffstat (limited to 'gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.test.js')
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.test.js20
1 files changed, 6 insertions, 14 deletions
diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.test.js
index 5e30924..cce6225 100644
--- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.test.js
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/MonitorInstantiation.test.js
@@ -17,7 +17,7 @@
* ============LICENSE_END=========================================================
*/
-import { mount, shallow } from "enzyme";
+import { shallow } from "enzyme";
import toJson from "enzyme-to-json";
import { createMemoryHistory } from "history";
import React from "react";
@@ -25,39 +25,31 @@ import MonitorInstantiation from "./MonitorInstantiation";
import { act } from "react-dom/test-utils";
describe('Verify MonitoringInstantiation', () => {
-
- it("renders without crashing", () => {
- shallow(<MonitorInstantiation/>);
- });
+ const container = shallow(<MonitorInstantiation />);
+ const containerWithHistory = shallow(<MonitorInstantiation history={ createMemoryHistory() }/>);
it("renders correctly", () => {
- const tree = shallow(<MonitorInstantiation/>);
- expect(toJson(tree)).toMatchSnapshot();
+ expect(toJson(container)).toMatchSnapshot();
});
it('should have a Button element', () => {
- const container = shallow(<MonitorInstantiation/>)
expect(container.find('Button').length).toEqual(1);
});
it('handleClose called when bottom button clicked', () => {
- const history = createMemoryHistory();
- const component = mount(<MonitorInstantiation history={ history }/>)
const logSpy = jest.spyOn(console, 'log');
act(() => {
- component.find('[variant="secondary"]').simulate('click');
+ containerWithHistory.find('[variant="secondary"]').simulate('click');
expect(logSpy).toHaveBeenCalledWith('handleClose called');
});
});
it('handleClose called when top-right button clicked', () => {
- const history = createMemoryHistory();
- const component = mount(<MonitorInstantiation history={ history }/>)
const logSpy = jest.spyOn(console, 'log');
act(() => {
- component.find('[size="xl"]').get(0).props.onHide();
+ containerWithHistory.find('[size="xl"]').get(0).props.onHide();
expect(logSpy).toHaveBeenCalledWith('handleClose called');
});
});