aboutsummaryrefslogtreecommitdiffstats
path: root/runtime/ui-react/src/components/dialogs/Loop/OpenLoopModal.test.js
diff options
context:
space:
mode:
authorLiam Fallon <liam.fallon@est.tech>2021-11-15 11:53:18 +0000
committerGerrit Code Review <gerrit@onap.org>2021-11-15 11:53:18 +0000
commitcb347e737f05d030fe781e15a9cf755cef42c80f (patch)
tree8919ef211d85b25b2e4edc94b40c678dabb87a85 /runtime/ui-react/src/components/dialogs/Loop/OpenLoopModal.test.js
parent496f58cf8f5ad6c65b417d2ae79a69ece480d049 (diff)
parent2022e5ce5a03788a6edc5761c495cfadc5ded485 (diff)
Merge "Align ui-react file in policy-clamp and policy-gui"
Diffstat (limited to 'runtime/ui-react/src/components/dialogs/Loop/OpenLoopModal.test.js')
-rw-r--r--runtime/ui-react/src/components/dialogs/Loop/OpenLoopModal.test.js49
1 files changed, 25 insertions, 24 deletions
diff --git a/runtime/ui-react/src/components/dialogs/Loop/OpenLoopModal.test.js b/runtime/ui-react/src/components/dialogs/Loop/OpenLoopModal.test.js
index 1865869df..6b2dc4afb 100644
--- a/runtime/ui-react/src/components/dialogs/Loop/OpenLoopModal.test.js
+++ b/runtime/ui-react/src/components/dialogs/Loop/OpenLoopModal.test.js
@@ -28,15 +28,15 @@ import LoopService from '../../../api/LoopService';
describe('Verify OpenLoopModal', () => {
beforeEach(() => {
- fetch.resetMocks();
- fetch.mockResponse(JSON.stringify([
- "LOOP_gmtAS_v1_0_ResourceInstanceName1_tca",
- "LOOP_gmtAS_v1_0_ResourceInstanceName1_tca_3",
- "LOOP_gmtAS_v1_0_ResourceInstanceName2_tca_2"
- ]));
+ fetch.resetMocks();
+ fetch.mockResponse(JSON.stringify([
+ "LOOP_gmtAS_v1_0_ResourceInstanceName1_tca",
+ "LOOP_gmtAS_v1_0_ResourceInstanceName1_tca_3",
+ "LOOP_gmtAS_v1_0_ResourceInstanceName2_tca_2"
+ ]));
});
- it('Test the render method', () => {
+ it('Test the render method', () => {
const component = shallow(<OpenLoopModal/>);
expect(component).toMatchSnapshot();
@@ -45,13 +45,14 @@ describe('Verify OpenLoopModal', () => {
it('Onchange event', async () => {
const flushPromises = () => new Promise(setImmediate);
LoopService.getLoop = jest.fn().mockImplementation(() => {
- return Promise.resolve({
- ok: true,
- status: 200,
- json: () => {}
- });
- });
- const event = {value: 'LOOP_gmtAS_v1_0_ResourceInstanceName1_tca_3'};
+ return Promise.resolve({
+ ok: true,
+ status: 200,
+ json: () => {
+ }
+ });
+ });
+ const event = { value: 'LOOP_gmtAS_v1_0_ResourceInstanceName1_tca_3' };
const component = shallow(<OpenLoopModal/>);
component.find('StateManager').simulate('change', event);
await flushPromises();
@@ -61,30 +62,30 @@ describe('Verify OpenLoopModal', () => {
it('Test handleClose', () => {
- const historyMock = { push: jest.fn() };
- const handleClose = jest.spyOn(OpenLoopModal.prototype,'handleClose');
- const component = shallow(<OpenLoopModal history={historyMock} />)
+ const historyMock = { push: jest.fn() };
+ const handleClose = jest.spyOn(OpenLoopModal.prototype, 'handleClose');
+ const component = shallow(<OpenLoopModal history={ historyMock }/>)
component.find('[variant="secondary"]').prop('onClick')();
expect(handleClose).toHaveBeenCalledTimes(1);
expect(component.state('show')).toEqual(false);
- expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
-
+ expect(historyMock.push.mock.calls[0]).toEqual(['/']);
+
handleClose.mockClear();
});
- it('Test handleSubmit', () => {
+ it('Test handleSubmit', () => {
const historyMock = { push: jest.fn() };
- const loadLoopFunction = jest.fn();
- const handleOpen = jest.spyOn(OpenLoopModal.prototype,'handleOpen');
- const component = shallow(<OpenLoopModal history={historyMock} loadLoopFunction={loadLoopFunction}/>)
+ const loadLoopFunction = jest.fn();
+ const handleOpen = jest.spyOn(OpenLoopModal.prototype, 'handleOpen');
+ const component = shallow(<OpenLoopModal history={ historyMock } loadLoopFunction={ loadLoopFunction }/>)
component.find('[variant="primary"]').prop('onClick')();
expect(handleOpen).toHaveBeenCalledTimes(1);
expect(component.state('show')).toEqual(false);
- expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
+ expect(historyMock.push.mock.calls[0]).toEqual(['/']);
handleOpen.mockClear();
});