mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-27 01:11:13 -06:00
about app unit test
This commit is contained in:
parent
663b512dc3
commit
600da210cd
203
spec/__snapshots__/aboutApp.spec.ts.snap
Normal file
203
spec/__snapshots__/aboutApp.spec.ts.snap
Normal file
@ -0,0 +1,203 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`about app should render correctly 1`] = `
|
||||
ShallowWrapper {
|
||||
Symbol(enzyme.__root__): [Circular],
|
||||
Symbol(enzyme.__unrendered__): <AboutApp />,
|
||||
Symbol(enzyme.__renderer__): Object {
|
||||
"batchedUpdates": [Function],
|
||||
"checkPropTypes": [Function],
|
||||
"getNode": [Function],
|
||||
"render": [Function],
|
||||
"simulateError": [Function],
|
||||
"simulateEvent": [Function],
|
||||
"unmount": [Function],
|
||||
},
|
||||
Symbol(enzyme.__node__): Object {
|
||||
"instance": null,
|
||||
"key": undefined,
|
||||
"nodeType": "host",
|
||||
"props": Object {
|
||||
"children": Array [
|
||||
<img
|
||||
className="AboutApp-logo"
|
||||
src="../assets/symphony-logo.png"
|
||||
/>,
|
||||
<span
|
||||
className="AboutApp-name"
|
||||
>
|
||||
Symphony
|
||||
</span>,
|
||||
<span
|
||||
className="AboutApp-versionText"
|
||||
>
|
||||
Version 0-N/A ()
|
||||
</span>,
|
||||
<span
|
||||
className="AboutApp-copyrightText"
|
||||
>
|
||||
Copyright © 2019 Symphony
|
||||
</span>,
|
||||
],
|
||||
"className": "AboutApp",
|
||||
},
|
||||
"ref": null,
|
||||
"rendered": Array [
|
||||
Object {
|
||||
"instance": null,
|
||||
"key": undefined,
|
||||
"nodeType": "host",
|
||||
"props": Object {
|
||||
"className": "AboutApp-logo",
|
||||
"src": "../assets/symphony-logo.png",
|
||||
},
|
||||
"ref": null,
|
||||
"rendered": null,
|
||||
"type": "img",
|
||||
},
|
||||
Object {
|
||||
"instance": null,
|
||||
"key": undefined,
|
||||
"nodeType": "host",
|
||||
"props": Object {
|
||||
"children": "Symphony",
|
||||
"className": "AboutApp-name",
|
||||
},
|
||||
"ref": null,
|
||||
"rendered": "Symphony",
|
||||
"type": "span",
|
||||
},
|
||||
Object {
|
||||
"instance": null,
|
||||
"key": undefined,
|
||||
"nodeType": "host",
|
||||
"props": Object {
|
||||
"children": "Version 0-N/A ()",
|
||||
"className": "AboutApp-versionText",
|
||||
},
|
||||
"ref": null,
|
||||
"rendered": "Version 0-N/A ()",
|
||||
"type": "span",
|
||||
},
|
||||
Object {
|
||||
"instance": null,
|
||||
"key": undefined,
|
||||
"nodeType": "host",
|
||||
"props": Object {
|
||||
"children": "Copyright © 2019 Symphony",
|
||||
"className": "AboutApp-copyrightText",
|
||||
},
|
||||
"ref": null,
|
||||
"rendered": "Copyright © 2019 Symphony",
|
||||
"type": "span",
|
||||
},
|
||||
],
|
||||
"type": "div",
|
||||
},
|
||||
Symbol(enzyme.__nodes__): Array [
|
||||
Object {
|
||||
"instance": null,
|
||||
"key": undefined,
|
||||
"nodeType": "host",
|
||||
"props": Object {
|
||||
"children": Array [
|
||||
<img
|
||||
className="AboutApp-logo"
|
||||
src="../assets/symphony-logo.png"
|
||||
/>,
|
||||
<span
|
||||
className="AboutApp-name"
|
||||
>
|
||||
Symphony
|
||||
</span>,
|
||||
<span
|
||||
className="AboutApp-versionText"
|
||||
>
|
||||
Version 0-N/A ()
|
||||
</span>,
|
||||
<span
|
||||
className="AboutApp-copyrightText"
|
||||
>
|
||||
Copyright © 2019 Symphony
|
||||
</span>,
|
||||
],
|
||||
"className": "AboutApp",
|
||||
},
|
||||
"ref": null,
|
||||
"rendered": Array [
|
||||
Object {
|
||||
"instance": null,
|
||||
"key": undefined,
|
||||
"nodeType": "host",
|
||||
"props": Object {
|
||||
"className": "AboutApp-logo",
|
||||
"src": "../assets/symphony-logo.png",
|
||||
},
|
||||
"ref": null,
|
||||
"rendered": null,
|
||||
"type": "img",
|
||||
},
|
||||
Object {
|
||||
"instance": null,
|
||||
"key": undefined,
|
||||
"nodeType": "host",
|
||||
"props": Object {
|
||||
"children": "Symphony",
|
||||
"className": "AboutApp-name",
|
||||
},
|
||||
"ref": null,
|
||||
"rendered": "Symphony",
|
||||
"type": "span",
|
||||
},
|
||||
Object {
|
||||
"instance": null,
|
||||
"key": undefined,
|
||||
"nodeType": "host",
|
||||
"props": Object {
|
||||
"children": "Version 0-N/A ()",
|
||||
"className": "AboutApp-versionText",
|
||||
},
|
||||
"ref": null,
|
||||
"rendered": "Version 0-N/A ()",
|
||||
"type": "span",
|
||||
},
|
||||
Object {
|
||||
"instance": null,
|
||||
"key": undefined,
|
||||
"nodeType": "host",
|
||||
"props": Object {
|
||||
"children": "Copyright © 2019 Symphony",
|
||||
"className": "AboutApp-copyrightText",
|
||||
},
|
||||
"ref": null,
|
||||
"rendered": "Copyright © 2019 Symphony",
|
||||
"type": "span",
|
||||
},
|
||||
],
|
||||
"type": "div",
|
||||
},
|
||||
],
|
||||
Symbol(enzyme.__options__): Object {
|
||||
"adapter": ReactSixteenAdapter {
|
||||
"options": Object {
|
||||
"enableComponentDidUpdateOnSetState": true,
|
||||
"legacyContextMode": "parent",
|
||||
"lifecycles": Object {
|
||||
"componentDidUpdate": Object {
|
||||
"onSetState": true,
|
||||
},
|
||||
"getChildContext": Object {
|
||||
"calledByRenderer": false,
|
||||
},
|
||||
"getDerivedStateFromProps": true,
|
||||
"getSnapshotBeforeUpdate": true,
|
||||
"setState": Object {
|
||||
"skipsComponentDidUpdateOnNullish": true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
Symbol(enzyme.__childContext__): null,
|
||||
}
|
||||
`;
|
38
spec/aboutApp.spec.ts
Normal file
38
spec/aboutApp.spec.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { shallow } from 'enzyme';
|
||||
import * as React from 'react';
|
||||
import AboutApp from '../src/renderer/components/about-app';
|
||||
import { ipcRenderer } from './__mocks__/electron';
|
||||
|
||||
describe('about app', () => {
|
||||
const aboutAppDataLabel = 'about-app-data';
|
||||
const aboutDataMock = { buildNumber: '4.x.x', clientVersion: '1', version: 'x.x.x' };
|
||||
const onLabelEvent = 'on';
|
||||
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);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user