mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-30 20:54:05 -06:00
e7f4470d9c
* SDA-2547 - Upgrade electron version to 14.0.1
* SDA-2547 - refactor and fix unit tests
* SDA-2555 - Move custom title bar away from remote module
* SDA-2555 - Update API new-window to setWindowOpenHandler and fix issues
* SDA-2555 - Arrange imports
* SDA-2555 - Fix unit tests
* SDA-3387 - Fixed reload, native notification issues & finally removed the SFE CSS injection 🎉
* SDA-2547 - Fix fullscreen state on Windows
* SDA-2552 - Update version info
* SDA-2548 - Fix media permission
* SDA-2547 - Get app name from package.json
80 lines
2.8 KiB
TypeScript
80 lines
2.8 KiB
TypeScript
import { shallow } from 'enzyme';
|
|
import * as React from 'react';
|
|
import { apiCmds } from '../src/common/api-interface';
|
|
import AboutApp from '../src/renderer/components/about-app';
|
|
import { ipcRenderer } from './__mocks__/electron';
|
|
|
|
describe('about app', () => {
|
|
const aboutAppDataLabel = 'about-app-data';
|
|
const aboutDataMock = {
|
|
sbeVersion: '1',
|
|
userConfig: {},
|
|
globalConfig: {},
|
|
cloudConfig: {},
|
|
finalConfig: {},
|
|
appName: 'Symphony',
|
|
versionLocalised: 'Version',
|
|
buildNumber: '4.x.x',
|
|
hostname: 'N/A',
|
|
sfeVersion: 'N/A',
|
|
sfeClientType: '1.5',
|
|
sdaVersion: '3.8.0',
|
|
sdaBuildNumber: '0',
|
|
electronVersion: '3.1.11',
|
|
chromeVersion: '66.789',
|
|
v8Version: '6.7.8',
|
|
nodeVersion: '10.12',
|
|
openSslVersion: '1.2.3',
|
|
zlibVersion: '4.5.6',
|
|
uvVersion: '7.8',
|
|
aresVersion: '9.10',
|
|
httpParserVersion: '11.12',
|
|
swiftSearchVersion: '1.55.3-beta.1',
|
|
swiftSearchSupportedVersion: 'N/A',
|
|
};
|
|
const onLabelEvent = 'on';
|
|
const ipcSendEvent = 'send';
|
|
const removeListenerLabelEvent = 'removeListener';
|
|
|
|
it('should render correctly', () => {
|
|
const wrapper = shallow(React.createElement(AboutApp));
|
|
expect(wrapper).toMatchSnapshot();
|
|
});
|
|
|
|
it('should call `about-app-data` event when component is mounted', () => {
|
|
const spy = jest.spyOn(ipcRenderer, onLabelEvent);
|
|
shallow(React.createElement(AboutApp));
|
|
expect(spy).toBeCalledWith(aboutAppDataLabel, expect.any(Function));
|
|
});
|
|
|
|
it('should remove listener `about-app-data` when component is unmounted', () => {
|
|
const spyMount = jest.spyOn(ipcRenderer, onLabelEvent);
|
|
const spyUnmount = jest.spyOn(ipcRenderer, removeListenerLabelEvent);
|
|
const wrapper = shallow(React.createElement(AboutApp));
|
|
expect(spyMount).toBeCalledWith(aboutAppDataLabel, expect.any(Function));
|
|
wrapper.unmount();
|
|
expect(spyUnmount).toBeCalledWith(aboutAppDataLabel, expect.any(Function));
|
|
});
|
|
|
|
it('should call `updateState` when component is mounted', () => {
|
|
const spy = jest.spyOn(AboutApp.prototype, 'setState');
|
|
shallow(React.createElement(AboutApp));
|
|
ipcRenderer.send('about-app-data', aboutDataMock);
|
|
expect(spy).toBeCalledWith(aboutDataMock);
|
|
});
|
|
|
|
it('should copy the correct data on to clipboard', () => {
|
|
const spyIpc = jest.spyOn(ipcRenderer, ipcSendEvent);
|
|
const wrapper = shallow(React.createElement(AboutApp));
|
|
ipcRenderer.send('about-app-data', aboutDataMock);
|
|
const copyButtonSelector = `button.AboutApp-copy-button[title="Copy all the version information in this page"]`;
|
|
wrapper.find(copyButtonSelector).simulate('click');
|
|
const expectedData = {
|
|
cmd: apiCmds.aboutAppClipBoardData,
|
|
clipboard: aboutDataMock,
|
|
clipboardType: 'clipboard',
|
|
};
|
|
expect(spyIpc).toBeCalledWith('symphony-api', expectedData);
|
|
});
|
|
});
|