mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-29 02:11:28 -06:00
c09eabbc8b
* ELECTRON-1463: support linux build * ELECTRON-1463: add scripts for linux build * ELECTRON-1463: fix unit tests * ELECTRON-1463: fix logger issue * ELECTRON-1463: fix menu not showing up * ELECTRON-1463: add screen-snippet functionality for linux * ELECTRON-1463: fix log path for linux * ELECTRON-1463: fix config path for linux * ELECTRON-1463: fix config path for linux * ELECTRON-1463: fix path in spellchecker * ELECTRON-1463: fix log path issues * ELECTRON-1463: remove unneeded dependencies and support rpm
76 lines
3.1 KiB
TypeScript
76 lines
3.1 KiB
TypeScript
import { shallow } from 'enzyme';
|
|
import * as React from 'react';
|
|
import ScreenSharingIndicator from '../src/renderer/components/screen-sharing-indicator';
|
|
import { ipcRenderer } from './__mocks__/electron';
|
|
|
|
jest.mock('../src/common/env', () => {
|
|
return {
|
|
isWindowsOS: false,
|
|
isMac: true,
|
|
isLinux: false,
|
|
};
|
|
});
|
|
|
|
describe('screen sharing indicator', () => {
|
|
// events
|
|
const onEventLabel = 'on';
|
|
const removeListenerEventLabel = 'removeListener';
|
|
const sendEventLabel = 'send';
|
|
const symphonyAPIEventLabel = 'symphony-api';
|
|
const screenSharingIndicatorDataEventLabel = 'screen-sharing-indicator-data';
|
|
// state moked
|
|
const screenSharingIndicatorStateMock = { id: 10 };
|
|
|
|
it('should render correctly', () => {
|
|
const wrapper = shallow(React.createElement(ScreenSharingIndicator));
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
it('should call `close` correctly', () => {
|
|
const customSelector = 'a.hide-button';
|
|
const closeIpcRendererMock = {
|
|
cmd: 'close-window',
|
|
windowType: 'screen-sharing-indicator',
|
|
winKey: 'id-123',
|
|
};
|
|
const spy = jest.spyOn(ipcRenderer, sendEventLabel);
|
|
const wrapper = shallow(React.createElement(ScreenSharingIndicator));
|
|
wrapper.setState({ streamId: 'id-123' });
|
|
wrapper.find(customSelector).simulate('click');
|
|
expect(spy).lastCalledWith(symphonyAPIEventLabel, closeIpcRendererMock);
|
|
});
|
|
|
|
it('should call `stopScreenShare` correctly', () => {
|
|
const customSelector = 'button.stop-sharing-button';
|
|
const stopScreenSharingEventLabel = 'stop-screen-sharing';
|
|
const spy = jest.spyOn(ipcRenderer, sendEventLabel);
|
|
const wrapper = shallow(React.createElement(ScreenSharingIndicator));
|
|
wrapper.setState(screenSharingIndicatorStateMock);
|
|
wrapper.find(customSelector).simulate('click');
|
|
expect(spy).lastCalledWith(stopScreenSharingEventLabel, 10);
|
|
});
|
|
|
|
it('should call `updateState` correctly', () => {
|
|
const setStateEventLabel = 'setState';
|
|
const spy = jest.spyOn(ScreenSharingIndicator.prototype, setStateEventLabel);
|
|
shallow(React.createElement(ScreenSharingIndicator));
|
|
ipcRenderer.send(screenSharingIndicatorDataEventLabel, screenSharingIndicatorStateMock);
|
|
expect(spy).lastCalledWith({ id: 10 });
|
|
});
|
|
|
|
describe('`screen-sharing-indicator-data` event', () => {
|
|
|
|
it('should call `screen-sharing-indicator-data` when component is mounted', () => {
|
|
const spy = jest.spyOn(ipcRenderer, onEventLabel);
|
|
shallow(React.createElement(ScreenSharingIndicator));
|
|
expect(spy).lastCalledWith(screenSharingIndicatorDataEventLabel, expect.any(Function));
|
|
});
|
|
|
|
it('should call `screen-sharing-indicator-data` when component is unmounted', () => {
|
|
const spy = jest.spyOn(ipcRenderer, removeListenerEventLabel);
|
|
shallow(React.createElement(ScreenSharingIndicator)).unmount();
|
|
expect(spy).toBeCalledWith(screenSharingIndicatorDataEventLabel, expect.any(Function));
|
|
});
|
|
});
|
|
});
|