summaryrefslogtreecommitdiffstats
path: root/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.test.js
diff options
context:
space:
mode:
authorxuegao <xg353y@intl.att.com>2019-10-02 11:18:10 +0200
committerxuegao <xg353y@intl.att.com>2019-10-04 09:42:00 +0200
commit564fdb0c2e601df73813a4e9d080bd1666befce4 (patch)
tree3e5c83ed368ab22e1c39dd38f7f18b681ef04d63 /ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.test.js
parentedec26efea06ee9a9d1e0f2d29fe4b26e62d8dfb (diff)
Add react ui test
Add react ui test to improve code coverage. Issue-ID: CLAMP-509 Change-Id: Ic9c974a78ee453dddb8f985f3e9c9067f66e95d9 Signed-off-by: xuegao <xg353y@intl.att.com>
Diffstat (limited to 'ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.test.js')
-rw-r--r--ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.test.js23
1 files changed, 12 insertions, 11 deletions
diff --git a/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.test.js b/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.test.js
index da60b6717..9c7da3108 100644
--- a/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.test.js
+++ b/ui-react/src/components/dialogs/OperationalPolicy/OperationalPolicyModal.test.js
@@ -28,13 +28,13 @@ import LoopCache from '../../../api/LoopCache';
describe('Verify OperationalPolicyModal', () => {
beforeEach(() => {
fetch.resetMocks();
- fetch.mockImplementation(() => {
- return Promise.resolve({
- ok: true,
- status: 200,
- text: () => "OK"
- });
- });
+ fetch.mockImplementation(() => {
+ return Promise.resolve({
+ ok: true,
+ status: 200,
+ text: () => "OK"
+ });
+ });
})
const loopCache = new LoopCache({
"name": "LOOP_Jbv1z_v1_0_ResourceInstanceName1_tca",
@@ -52,7 +52,7 @@ describe('Verify OperationalPolicyModal', () => {
});
const historyMock = { push: jest.fn() };
const flushPromises = () => new Promise(setImmediate);
-
+
it('Test handleClose', () => {
const handleClose = jest.spyOn(OperationalPolicyModal.prototype,'handleClose');
const component = mount(<OperationalPolicyModal history={historyMock} loopCache={loopCache}/>)
@@ -61,13 +61,14 @@ describe('Verify OperationalPolicyModal', () => {
expect(handleClose).toHaveBeenCalledTimes(1);
expect(component.state('show')).toEqual(false);
- expect(historyMock.push.mock.calls[0]).toEqual([ '/', ]);
+ expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
});
it('Test handleSave', async () => {
const loadLoopFunction = jest.fn();
const handleSave = jest.spyOn(OperationalPolicyModal.prototype,'handleSave');
- const component = mount(<OperationalPolicyModal history={historyMock} loopCache={loopCache} loadLoopFunction={loadLoopFunction} />)
+ const component = mount(<OperationalPolicyModal history={historyMock}
+ loopCache={loopCache} loadLoopFunction={loadLoopFunction} />)
component.find('[variant="primary"]').prop('onClick')();
await flushPromises();
@@ -75,6 +76,6 @@ describe('Verify OperationalPolicyModal', () => {
expect(handleSave).toHaveBeenCalledTimes(1);
expect(component.state('show')).toEqual(false);
- expect(historyMock.push.mock.calls[0]).toEqual([ '/', ]);
+ expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
});
}); \ No newline at end of file