Create SVG in UI
[clamp.git] / ui-react / src / components / dialogs / Tosca / ViewLoopTemplatesModal.test.js
index 94d4acd..7680ec4 100644 (file)
@@ -24,12 +24,12 @@ import React from 'react';
 import { shallow } from 'enzyme';
 import ViewLoopTemplatesModal from './ViewLoopTemplatesModal';
 import { mount } from 'enzyme';
+import { BrowserRouter as Router } from 'react-router-dom';
 
 describe('Verify ViewLoopTemplatesModal', () => {
        beforeEach(() => {
                fetch.resetMocks();
-               }
-       );
+       });
 
        it('Test API Successful', () => {
                fetch.mockImplementationOnce(() => {
@@ -74,11 +74,10 @@ describe('Verify ViewLoopTemplatesModal', () => {
        it('Test API Rejection', () => {
                const myMockFunc  = fetch.mockImplementationOnce(() => Promise.reject('error'));
                setTimeout( () => myMockFunc().catch(e => {
-                       console.log(e);
+                       console.info(e);
                }),
                100
                );
-               new Promise(resolve => setTimeout(resolve, 200));
                const component = shallow(<ViewLoopTemplatesModal/>);
                expect(myMockFunc.mock.calls.length).toBe(1);
        });
@@ -130,32 +129,9 @@ describe('Verify ViewLoopTemplatesModal', () => {
                                        }
                                });
                        });
-                       const component = mount(<ViewLoopTemplatesModal/>);
+                       const component = mount(<Router><ViewLoopTemplatesModal/></Router>);
                        expect(component.find('[className="MuiSelect-icon MuiTablePagination-selectIcon"]')).toBeTruthy();
                });
-
-               it('Test handleYamlContent', () => {
-                       fetch.mockImplementationOnce(() => {
-                               return Promise.resolve({
-                                       ok: true,
-                                       status: 200,
-                                       json: () => {
-                                               return Promise.resolve({
-                                               "index": "1",
-                                               "name": "MTCA version 1",
-                                               "modelService.serviceDetails.name": "MTCA",
-                                               "allowedLoopType" : "CLOSED",
-                                               "maximumInstancesAllowed":1,
-                                               "updatedDate":"2019-09-06 19:09:42"
-                                               });
-                                       }
-                               });
-                       });
-                       const yamlContent = 'MTCA version 1';
-                       const component = shallow(<ViewLoopTemplatesModal/>);
-                       component.find('[value="Please select a loop template to display it"]').prop('onChange')({ target: { value: yamlContent }});
-                       expect(component.state('content')).toEqual(yamlContent);
-               });
                
                it('Test handleClose', () => {
                        fetch.mockImplementationOnce(() => {
@@ -183,4 +159,4 @@ describe('Verify ViewLoopTemplatesModal', () => {
                        expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
                        handleClose.mockClear();
                });
-       });
\ No newline at end of file
+       });