summaryrefslogtreecommitdiffstats
path: root/gui-clamp/ui-react/src/components/dialogs/ControlLoop/InstancePropertiesModal.test.js
diff options
context:
space:
mode:
authorbrunomilitzer <bruno.militzer@est.tech>2022-01-10 17:06:32 +0000
committerbrunomilitzer <bruno.militzer@est.tech>2022-01-11 12:05:55 +0000
commit3eb9e8975b8d9e1f44106b3c9c4c6d8b711ad3a2 (patch)
tree00d41e96baa2fe2096245bb0f4ab99b594c3578a /gui-clamp/ui-react/src/components/dialogs/ControlLoop/InstancePropertiesModal.test.js
parent4be96f85c65df9384b11d68e87ca9e03e27a083c (diff)
Added Test Code Coverage
Issue-ID: POLICY-3563 Change-Id: I65cd2bfc72b973baa8f2b28a14e5d364ca4562a2 Signed-off-by: brunomilitzer <bruno.militzer@est.tech>
Diffstat (limited to 'gui-clamp/ui-react/src/components/dialogs/ControlLoop/InstancePropertiesModal.test.js')
-rw-r--r--gui-clamp/ui-react/src/components/dialogs/ControlLoop/InstancePropertiesModal.test.js34
1 files changed, 27 insertions, 7 deletions
diff --git a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/InstancePropertiesModal.test.js b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/InstancePropertiesModal.test.js
index 454fcf9..5c617bf 100644
--- a/gui-clamp/ui-react/src/components/dialogs/ControlLoop/InstancePropertiesModal.test.js
+++ b/gui-clamp/ui-react/src/components/dialogs/ControlLoop/InstancePropertiesModal.test.js
@@ -1,6 +1,6 @@
/*
* ============LICENSE_START=======================================================
- * Copyright (C) 2021 Nordix Foundation.
+ * 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.
@@ -23,17 +23,29 @@ import InstancePropertiesModal from "./InstancePropertiesModal";
import toJson from "enzyme-to-json";
import { createMemoryHistory } from "history";
import { act } from "react-dom/test-utils";
-import ControlLoopService from "../../../api/ControlLoopService";
-import instanceProps from "./testFiles/instanceProps.json";
-import fullTemp from "./testFiles/fullTemplate.json";
-
let logSpy = jest.spyOn(console, 'log')
-const instanceProperties = JSON.parse(JSON.stringify(instanceProps))
-const fullTemplate = JSON.parse(JSON.stringify(fullTemp))
describe('Verify InstancePropertiesModal', () => {
+ const unmockedFetch = global.fetch
+ beforeAll(() => {
+ global.fetch = () =>
+ Promise.resolve({
+ status: 200,
+ text: () => "OK",
+ json: () => "{GlobalFetch}"
+ });
+ });
+
+ afterAll(() => {
+ global.fetch = unmockedFetch
+ });
+
+ beforeEach(() => {
+ logSpy.mockClear()
+ });
+
it("renders without crashing", () => {
shallow(<InstancePropertiesModal />);
});
@@ -80,4 +92,12 @@ describe('Verify InstancePropertiesModal', () => {
expect(logSpy).toHaveBeenCalledWith('handleSave called');
});
});
+
+ it('Check useEffect is being called', async () => {
+ const useEffect = jest.spyOn(React, "useEffect");
+ mount(<InstancePropertiesModal />)
+ await act(async () => {
+ expect(useEffect).toHaveBeenCalled();
+ });
+ });
});