Merge "Removal of Svg api"
[clamp.git] / ui-react / src / LoopUI.test.js
index e28096b..bfd6376 100644 (file)
@@ -23,6 +23,7 @@
 import React from 'react';
 import { shallow } from 'enzyme';
 import LoopUI from './LoopUI';
+import OnapConstants from './utils/OnapConstants';
 
 import LoopCache from './api/LoopCache';
 import LoopActionService from './api/LoopActionService';
@@ -65,7 +66,8 @@ describe('Verify LoopUI', () => {
                const component = shallow(<LoopUI />)
                component.setState({
                        loopName: "testLoopName",
-                       showAlert: false 
+                       showSucAlert: false,
+                       showFailAlert: false 
                });
                await flushPromises();
                expect(component).toMatchSnapshot();
@@ -77,19 +79,10 @@ describe('Verify LoopUI', () => {
                const instance = component.instance();
                instance.closeLoop();
                        
-               expect(component.state('loopName')).toEqual("Empty (NO loop loaded yet)");
+               expect(component.state('loopName')).toEqual(OnapConstants.defaultLoopName);
                expect(historyMock.push.mock.calls[0]).toEqual([ '/']);
        })
 
-       test('Test logout method', async () => {
-               const flushPromises = () => new Promise(setImmediate);
-               const component = shallow(<LoopUI />)
-               const instance = component.instance();
-               instance.logout();
-               await flushPromises();
-               expect(component.state('userName')).toEqual("testUser");
-       })
-
        test('Test loadLoop method refresh suc', async () => {
                const historyMock = { push: jest.fn() };
                LoopService.getLoop = jest.fn().mockImplementation(() => {
@@ -157,15 +150,22 @@ describe('Verify LoopUI', () => {
 
        test('Test alert methods', () => {
                const component = shallow(<LoopUI />)
-               expect(component.state('showAlert')).toEqual(false);
+               expect(component.state('showSucAlert')).toEqual(false);
 
                const instance = component.instance();
-               instance.showAlert("testAlert");
-               expect(component.state('showAlert')).toEqual(true);
+               instance.showSucAlert("testAlert");
+               expect(component.state('showSucAlert')).toEqual(true);
+               expect(component.state('showFailAlert')).toEqual(false);
                expect(component.state('showMessage')).toEqual("testAlert");
 
                instance.disableAlert();
                        
-               expect(component.state('showAlert')).toEqual(false);
+               expect(component.state('showSucAlert')).toEqual(false);
+               expect(component.state('showFailAlert')).toEqual(false);
+
+               instance.showFailAlert("testAlert2");
+               expect(component.state('showSucAlert')).toEqual(false);
+               expect(component.state('showFailAlert')).toEqual(true);
+               expect(component.state('showMessage')).toEqual("testAlert2");
        })
 });