screen picker unit test (#587)

* screen picker unit test

* screen sharing indicator unit test
This commit is contained in:
VICTOR RAPHAEL BRAGA DE SALES MASCARENHAS 2019-03-13 04:00:59 -03:00 committed by Kiran Niranjan
parent 8d2fa4f049
commit e950a39a48
6 changed files with 1274 additions and 14 deletions

View File

@ -38,7 +38,7 @@ const pathToConfigDir = (): string => {
};
// electron app mock...
const app: IApp = {
export const app: IApp = {
getAppPath: pathToConfigDir,
getPath: (type) => {
if (type === 'exe') {
@ -56,7 +56,7 @@ const app: IApp = {
// simple ipc mocks for render and main process ipc using
// nodes' EventEmitter
const ipcMain: IIpcMain = {
export const ipcMain: IIpcMain = {
on: (event, cb) => {
ipcEmitter.on(event, cb);
},
@ -72,11 +72,11 @@ const ipcMain: IIpcMain = {
},
};
const powerMonitor: IPowerMonitor = {
export const powerMonitor: IPowerMonitor = {
querySystemIdleTime: jest.fn().mockImplementation((cb) => cb(mockIdleTime)),
};
const ipcRenderer: IIpcRenderer = {
export const ipcRenderer: IIpcRenderer = {
sendSync: (event, args) => {
const listeners = ipcEmitter.listeners(event);
if (listeners.length > 0) {
@ -105,13 +105,6 @@ const ipcRenderer: IIpcRenderer = {
},
};
export = {
export const remote = {
app,
ipcMain,
ipcRenderer,
powerMonitor,
require: jest.fn(),
match: jest.fn(),
remote: jest.fn(),
dialog: jest.fn(),
};

View File

@ -0,0 +1,591 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`screen picker should render correctly 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <ScreenPicker />,
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 [
<div
className="ScreenPicker-title"
>
<span>
Choose what you'd like to share
</span>
<div
className="ScreenPicker-x-button"
onClick={[Function]}
>
<div
className="content-button"
>
<i>
<svg
fill="grey"
viewBox="0 0 48 48"
>
<path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>
</svg>
</i>
</div>
</div>
</div>,
<div
className="ScreenPicker-error-content"
>
<span
className="error-message"
>
No screens or applications are currently available.
</span>
</div>,
<footer>
<button
className="ScreenPicker-cancel-button"
onClick={[Function]}
>
Cancel
</button>
<button
className="ScreenPicker-share-button ScreenPicker-share-button-disable"
onClick={[Function]}
>
Select Screen
</button>
</footer>,
],
"className": "ScreenPicker ScreenPicker-content",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<span>
Choose what you'd like to share
</span>,
<div
className="ScreenPicker-x-button"
onClick={[Function]}
>
<div
className="content-button"
>
<i>
<svg
fill="grey"
viewBox="0 0 48 48"
>
<path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>
</svg>
</i>
</div>
</div>,
],
"className": "ScreenPicker-title",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Choose what you'd like to share",
},
"ref": null,
"rendered": "Choose what you'd like to share",
"type": "span",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <div
className="content-button"
>
<i>
<svg
fill="grey"
viewBox="0 0 48 48"
>
<path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>
</svg>
</i>
</div>,
"className": "ScreenPicker-x-button",
"onClick": [Function],
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <i>
<svg
fill="grey"
viewBox="0 0 48 48"
>
<path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>
</svg>
</i>,
"className": "content-button",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <svg
fill="grey"
viewBox="0 0 48 48"
>
<path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>
</svg>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>,
"fill": "grey",
"viewBox": "0 0 48 48",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"d": "M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z",
},
"ref": null,
"rendered": null,
"type": "path",
},
"type": "svg",
},
"type": "i",
},
"type": "div",
},
"type": "div",
},
],
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <span
className="error-message"
>
No screens or applications are currently available.
</span>,
"className": "ScreenPicker-error-content",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "No screens or applications are currently available.",
"className": "error-message",
},
"ref": null,
"rendered": "No screens or applications are currently available.",
"type": "span",
},
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<button
className="ScreenPicker-cancel-button"
onClick={[Function]}
>
Cancel
</button>,
<button
className="ScreenPicker-share-button ScreenPicker-share-button-disable"
onClick={[Function]}
>
Select Screen
</button>,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Cancel",
"className": "ScreenPicker-cancel-button",
"onClick": [Function],
},
"ref": null,
"rendered": "Cancel",
"type": "button",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Select Screen",
"className": "ScreenPicker-share-button ScreenPicker-share-button-disable",
"onClick": [Function],
},
"ref": null,
"rendered": "Select Screen",
"type": "button",
},
],
"type": "footer",
},
],
"type": "div",
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<div
className="ScreenPicker-title"
>
<span>
Choose what you'd like to share
</span>
<div
className="ScreenPicker-x-button"
onClick={[Function]}
>
<div
className="content-button"
>
<i>
<svg
fill="grey"
viewBox="0 0 48 48"
>
<path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>
</svg>
</i>
</div>
</div>
</div>,
<div
className="ScreenPicker-error-content"
>
<span
className="error-message"
>
No screens or applications are currently available.
</span>
</div>,
<footer>
<button
className="ScreenPicker-cancel-button"
onClick={[Function]}
>
Cancel
</button>
<button
className="ScreenPicker-share-button ScreenPicker-share-button-disable"
onClick={[Function]}
>
Select Screen
</button>
</footer>,
],
"className": "ScreenPicker ScreenPicker-content",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<span>
Choose what you'd like to share
</span>,
<div
className="ScreenPicker-x-button"
onClick={[Function]}
>
<div
className="content-button"
>
<i>
<svg
fill="grey"
viewBox="0 0 48 48"
>
<path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>
</svg>
</i>
</div>
</div>,
],
"className": "ScreenPicker-title",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Choose what you'd like to share",
},
"ref": null,
"rendered": "Choose what you'd like to share",
"type": "span",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <div
className="content-button"
>
<i>
<svg
fill="grey"
viewBox="0 0 48 48"
>
<path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>
</svg>
</i>
</div>,
"className": "ScreenPicker-x-button",
"onClick": [Function],
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <i>
<svg
fill="grey"
viewBox="0 0 48 48"
>
<path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>
</svg>
</i>,
"className": "content-button",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <svg
fill="grey"
viewBox="0 0 48 48"
>
<path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>
</svg>,
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <path
d="M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z"
/>,
"fill": "grey",
"viewBox": "0 0 48 48",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"d": "M39.4,33.8L31,25.4c-0.4-0.4-0.9-0.9-1.4-1.4c0.5-0.5,1-1,1.4-1.4l8.4-8.4c0.8-0.8,0.8-2,0-2.8l-2.8-2.8 c-0.8-0.8-2-0.8-2.8,0L25.4,17c-0.4,0.4-0.9,0.9-1.4,1.4c-0.5-0.5-1-1-1.4-1.4l-8.4-8.4c-0.8-0.8-2-0.8-2.8,0l-2.8,2.8 c-0.8,0.8-0.8,2,0,2.8l8.4,8.4c0.4,0.4,0.9,0.9,1.4,1.4c-0.5,0.5-1,1-1.4,1.4l-8.4,8.4c-0.8,0.8-0.8,2,0,2.8l2.8,2.8 c0.8,0.8,2,0.8,2.8,0l8.4-8.4c0.4-0.4,0.9-0.9,1.4-1.4c0.5,0.5,1,1,1.4,1.4l8.4,8.4c0.8,0.8,2,0.8,2.8,0l2.8-2.8 C40.2,35.8,40.2,34.6,39.4,33.8z",
},
"ref": null,
"rendered": null,
"type": "path",
},
"type": "svg",
},
"type": "i",
},
"type": "div",
},
"type": "div",
},
],
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": <span
className="error-message"
>
No screens or applications are currently available.
</span>,
"className": "ScreenPicker-error-content",
},
"ref": null,
"rendered": Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "No screens or applications are currently available.",
"className": "error-message",
},
"ref": null,
"rendered": "No screens or applications are currently available.",
"type": "span",
},
"type": "div",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<button
className="ScreenPicker-cancel-button"
onClick={[Function]}
>
Cancel
</button>,
<button
className="ScreenPicker-share-button ScreenPicker-share-button-disable"
onClick={[Function]}
>
Select Screen
</button>,
],
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Cancel",
"className": "ScreenPicker-cancel-button",
"onClick": [Function],
},
"ref": null,
"rendered": "Cancel",
"type": "button",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Select Screen",
"className": "ScreenPicker-share-button ScreenPicker-share-button-disable",
"onClick": [Function],
},
"ref": null,
"rendered": "Select Screen",
"type": "button",
},
],
"type": "footer",
},
],
"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,
}
`;

View File

@ -0,0 +1,273 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`screen sharing indicator should render correctly 1`] = `
ShallowWrapper {
Symbol(enzyme.__root__): [Circular],
Symbol(enzyme.__unrendered__): <ScreenSharingIndicator />,
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 [
<span
className="drag-area"
/>,
<span
className="text-label"
>
You are sharing your screen on Symphony
</span>,
<span
className="buttons"
>
<a
className="hide-button"
href="#"
onClick={[Function]}
>
Hide
</a>
<button
className="stop-sharing-button"
onClick={[Function]}
>
Stop sharing
</button>
</span>,
],
"className": "ScreenSharingIndicator mac",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"className": "drag-area",
},
"ref": null,
"rendered": null,
"type": "span",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "You are sharing your screen on Symphony",
"className": "text-label",
},
"ref": null,
"rendered": "You are sharing your screen on Symphony",
"type": "span",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<a
className="hide-button"
href="#"
onClick={[Function]}
>
Hide
</a>,
<button
className="stop-sharing-button"
onClick={[Function]}
>
Stop sharing
</button>,
],
"className": "buttons",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Hide",
"className": "hide-button",
"href": "#",
"onClick": [Function],
},
"ref": null,
"rendered": "Hide",
"type": "a",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Stop sharing",
"className": "stop-sharing-button",
"onClick": [Function],
},
"ref": null,
"rendered": "Stop sharing",
"type": "button",
},
],
"type": "span",
},
],
"type": "div",
},
Symbol(enzyme.__nodes__): Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<span
className="drag-area"
/>,
<span
className="text-label"
>
You are sharing your screen on Symphony
</span>,
<span
className="buttons"
>
<a
className="hide-button"
href="#"
onClick={[Function]}
>
Hide
</a>
<button
className="stop-sharing-button"
onClick={[Function]}
>
Stop sharing
</button>
</span>,
],
"className": "ScreenSharingIndicator mac",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"className": "drag-area",
},
"ref": null,
"rendered": null,
"type": "span",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "You are sharing your screen on Symphony",
"className": "text-label",
},
"ref": null,
"rendered": "You are sharing your screen on Symphony",
"type": "span",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": Array [
<a
className="hide-button"
href="#"
onClick={[Function]}
>
Hide
</a>,
<button
className="stop-sharing-button"
onClick={[Function]}
>
Stop sharing
</button>,
],
"className": "buttons",
},
"ref": null,
"rendered": Array [
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Hide",
"className": "hide-button",
"href": "#",
"onClick": [Function],
},
"ref": null,
"rendered": "Hide",
"type": "a",
},
Object {
"instance": null,
"key": undefined,
"nodeType": "host",
"props": Object {
"children": "Stop sharing",
"className": "stop-sharing-button",
"onClick": [Function],
},
"ref": null,
"rendered": "Stop sharing",
"type": "button",
},
],
"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,
}
`;

View File

@ -100,7 +100,7 @@ describe('download manager', () => {
const onLabelEvent: string = 'on';
const removeListenerLabelEvent: string = 'removeListener';
it('should call the `downloadCompleted event when mount component', () => {
it('should call the `downloadCompleted event when component is mounted', () => {
const spy: jest.SpyInstance = jest.spyOn(ipcRenderer, onLabelEvent);
shallow(React.createElement(DownloadManager));
@ -108,7 +108,7 @@ describe('download manager', () => {
expect(spy).toBeCalledWith(downloadCompletedLabelEvent, expect.any(Function));
});
it('should remove listen `downloadCompleted` when component is unmount', () => {
it('should remove listen `downloadCompleted` when component is unmounted', () => {
const spyMount: jest.SpyInstance = jest.spyOn(ipcRenderer, onLabelEvent);
const spyUnmount: jest.SpyInstance = jest.spyOn(ipcRenderer, removeListenerLabelEvent);
const wrapper: ShallowWrapper = shallow(React.createElement(DownloadManager));

331
spec/screenPicker.spec.ts Normal file
View File

@ -0,0 +1,331 @@
import { shallow } from 'enzyme';
import * as React from 'react';
import ScreenPicker from '../src/renderer/components/screen-picker';
import { ipcRenderer } from './__mocks__/electron';
jest.mock('../src/common/env', () => {
return {
isWindowsOS: false,
isMac: true,
};
});
describe('screen picker', () => {
const keyCode = {
pageDown: { keyCode: 34 },
rightArrow: { keyCode: 39 },
pageUp: { keyCode: 33 },
leftArrow: { keyCode: 37 },
homeKey: { keyCode: 36 },
upArrow: { keyCode: 38 },
endKey: { keyCode: 35 },
downArrow: { keyCode: 40 },
enterKey: { keyCode: 13 },
escapeKey: { keyCode: 27 },
random: { keyCode: 100 },
};
const sendEventLabel = 'send';
const screenSourceSelectedLabel = 'screen-source-selected';
const symphonyApiLabel = 'symphony-api';
const screenTabCustomSelector = '#screen-tab';
const applicationTabCustomSelector = '#application-tab';
const screenPickerDataLabel = 'screen-picker-data';
const events = {
keyup: jest.fn(),
};
const stateMock = {
sources: [
{ display_id: '0', id: '0', name: 'Application screen 0', thumbnail: undefined },
{ display_id: '1', id: '1', name: 'Application screen 1', thumbnail: undefined },
{ display_id: '2', id: '2', name: 'Application screen 2', thumbnail: undefined },
],
selectedSource: { display_id: '1', id: '1', name: 'Application screen 1', thumbnail: undefined },
};
it('should render correctly', () => {
const wrapper = shallow(React.createElement(ScreenPicker));
expect(wrapper).toMatchSnapshot();
});
it('should call `close` correctly', () => {
const wrapper = shallow(React.createElement(ScreenPicker));
const spy = jest.spyOn(ipcRenderer, sendEventLabel);
const customSelector = 'button.ScreenPicker-cancel-button';
const expectedValue = { cmd: 'close-window', windowType: 'screen-picker' };
wrapper.find(customSelector).simulate('click');
expect(spy).nthCalledWith(1, screenSourceSelectedLabel, null);
expect(spy).nthCalledWith(2, symphonyApiLabel, expectedValue);
});
it('should call `submit` correctly', () => {
const wrapper = shallow(React.createElement(ScreenPicker));
const spy = jest.spyOn(ipcRenderer, sendEventLabel);
const selectedSource = { display_id: '1', id: '1', name: 'Entire screen', thumbnail: undefined };
const customSelector = 'button.ScreenPicker-share-button';
wrapper.setState({ selectedSource });
wrapper.find(customSelector).simulate('click');
expect(spy).lastCalledWith(screenSourceSelectedLabel, selectedSource);
});
it('should call `updateState` correctly', () => {
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const updateState = {
sources: [ { display_id: '0', id: '0', name: 'Entire screen', thumbnail: undefined } ],
selectedSource: undefined,
selectedTab: 'screens',
};
shallow(React.createElement(ScreenPicker));
ipcRenderer.send(screenPickerDataLabel, updateState);
expect(spy).toBeCalledWith(updateState);
});
describe('`onToggle` event', () => {
const entireScreenStateMock = {
sources: [
{ display_id: '0', id: '0', name: 'Entire screen', thumbnail: undefined },
],
selectedSource: { display_id: '0', id: '0', name: 'Entire screen', thumbnail: undefined },
};
const applicationScreenStateMock = {
sources: [
{ display_id: '0', id: '0', name: 'Application screen 0', thumbnail: undefined },
],
selectedSource: { display_id: '0', id: '0', name: 'Application screen 0', thumbnail: undefined },
};
it('should call `onToggle` when screen tab is changed', () => {
const wrapper = shallow(React.createElement(ScreenPicker));
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const expectedValue = { selectedTab: 'screens' };
wrapper.setState(entireScreenStateMock);
wrapper.find(screenTabCustomSelector).simulate('change');
expect(spy).lastCalledWith(expectedValue);
});
it('should call `onToggle` when application tab is changed', () => {
const wrapper = shallow(React.createElement(ScreenPicker));
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const expectedValue = { selectedTab: 'applications' };
wrapper.setState(applicationScreenStateMock);
wrapper.find(applicationTabCustomSelector).simulate('change');
expect(spy).lastCalledWith(expectedValue);
});
});
describe('onSelect event', () => {
it('should call `onSelect` when `ScreenPicker-item-container` in Entire screen is clicked', () => {
const wrapper = shallow(React.createElement(ScreenPicker));
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const expectedValue = { selectedSource: { display_id: '0', id: '0', name: 'Entire screen', thumbnail: undefined }};
const customSelector = '.ScreenPicker-item-container';
const applicationScreenStateMock = {
sources: [
{ display_id: '0', id: '0', name: 'Entire screen', thumbnail: undefined },
{ display_id: '1', id: '1', name: 'Application screen 1', thumbnail: undefined },
{ display_id: '2', id: '2', name: 'Application screen 2', thumbnail: undefined },
],
selectedSource: { display_id: '1', id: '1', name: 'Application screen 1', thumbnail: undefined },
};
wrapper.setState(applicationScreenStateMock);
wrapper.find(customSelector).first().simulate('click');
expect(spy).lastCalledWith(expectedValue);
});
it('should call `onSelect` when `ScreenPicker-item-container` in Application screen is clicked', () => {
const wrapper = shallow(React.createElement(ScreenPicker));
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const expectedValue = { selectedSource: { display_id: '2', id: '2', name: 'Application screen 2', thumbnail: undefined }};
const customSelector = '.ScreenPicker-item-container';
const applicationScreenStateMock = {
sources: [
{ display_id: '0', id: '0', name: 'Entire screen', thumbnail: undefined },
{ display_id: '1', id: '1', name: 'Application screen 1', thumbnail: undefined },
{ display_id: '2', id: '2', name: 'Application screen 2', thumbnail: undefined },
],
selectedSource: { display_id: '1', id: '1', name: 'Application screen 1', thumbnail: undefined },
};
wrapper.setState(applicationScreenStateMock);
wrapper.find(customSelector).at(2).simulate('click');
expect(spy).lastCalledWith(expectedValue);
});
});
describe('handle keyUp', () => {
beforeAll(() => {
document.addEventListener = jest.fn((event, cb) => {
events[event] = cb;
});
});
it('should register `keyup` when component is mounted', () => {
const spy = jest.spyOn(document, 'addEventListener');
shallow(React.createElement(ScreenPicker));
events.keyup(keyCode.random);
expect(spy).lastCalledWith('keyup', expect.any(Function), true);
});
it('should remove event `keyup` when component is unmounted', () => {
const spy = jest.spyOn(document, 'removeEventListener');
shallow(React.createElement(ScreenPicker)).unmount();
expect(spy).lastCalledWith('keyup', expect.any(Function), true);
});
it('should call `handleKeyUpPress` pageDown key correctly', () => {
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const expectedValue = { selectedSource: { display_id: '2', id: '2', name: 'Application screen 2', thumbnail: undefined }};
const wrapper = shallow(React.createElement(ScreenPicker));
wrapper.setState(stateMock);
events.keyup(keyCode.pageDown);
expect(spy).lastCalledWith(expectedValue);
});
it('should call `handleKeyUpPress` right arrow key correctly', () => {
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const expectedValue = { selectedSource: { display_id: '2', id: '2', name: 'Application screen 2', thumbnail: undefined }};
const wrapper = shallow(React.createElement(ScreenPicker));
wrapper.setState(stateMock);
events.keyup(keyCode.rightArrow);
expect(spy).lastCalledWith(expectedValue);
});
it('should call `handleKeyUpPress` pageUp key correctly', () => {
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const expectedValue = { selectedSource: { display_id: '0', id: '0', name: 'Application screen 0', thumbnail: undefined }};
const wrapper = shallow(React.createElement(ScreenPicker));
wrapper.setState(stateMock);
events.keyup(keyCode.pageUp);
expect(spy).lastCalledWith(expectedValue);
});
it('should call `handleKeyUpPress` left arrow key correctly', () => {
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const expectedValue = { selectedSource: { display_id: '0', id: '0', name: 'Application screen 0', thumbnail: undefined }};
const wrapper = shallow(React.createElement(ScreenPicker));
wrapper.setState(stateMock);
events.keyup(keyCode.leftArrow);
expect(spy).lastCalledWith(expectedValue);
});
it('should call `handleKeyUpPress` down arrow key correctly', () => {
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const expectedValue = { selectedSource: { display_id: '0', id: '0', name: 'Application screen 0', thumbnail: undefined }};
const wrapper = shallow(React.createElement(ScreenPicker));
wrapper.setState(stateMock);
events.keyup(keyCode.downArrow);
expect(spy).lastCalledWith(expectedValue);
});
it('should call `handleKeyUpPress` up arrow key correctly', () => {
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const expectedValue = { selectedSource: { display_id: '2', id: '2', name: 'Application screen 2', thumbnail: undefined }};
const wrapper = shallow(React.createElement(ScreenPicker));
wrapper.setState(stateMock);
events.keyup(keyCode.upArrow);
expect(spy).lastCalledWith(expectedValue);
});
it('should call `handleKeyUpPress` enter key correctly', () => {
const spy = jest.spyOn(ipcRenderer, sendEventLabel);
const expectedValue = { display_id: '1', id: '1', name: 'Application screen 1', thumbnail: undefined };
const wrapper = shallow(React.createElement(ScreenPicker));
wrapper.setState(stateMock);
events.keyup(keyCode.enterKey);
expect(spy).lastCalledWith(screenSourceSelectedLabel, expectedValue);
});
it('should call `handleKeyUpPress` escape key correctly', () => {
const spy = jest.spyOn(ipcRenderer, sendEventLabel);
const expectedValue = { cmd: 'close-window', windowType: 'screen-picker' };
const wrapper = shallow(React.createElement(ScreenPicker));
wrapper.setState(stateMock);
events.keyup(keyCode.escapeKey);
expect(spy).nthCalledWith(1, screenSourceSelectedLabel, null);
expect(spy).nthCalledWith(2, symphonyApiLabel, expectedValue);
});
it('should call `handleKeyUpPress` end key correctly', () => {
const spy = jest.spyOn(ScreenPicker.prototype, 'setState');
const expectedValue = { selectedSource: { display_id: '0', id: '0', name: 'Application screen 0', thumbnail: undefined }};
const wrapper = shallow(React.createElement(ScreenPicker));
wrapper.setState(stateMock);
events.keyup(keyCode.endKey);
expect(spy).lastCalledWith(expectedValue);
});
});
describe('tab titles', () => {
it('should show `application-tab` when source name is not Entire screen', () => {
const wrapper = shallow(React.createElement(ScreenPicker));
const applicationScreenStateMock = {
sources: [
{ display_id: '1', id: '1', name: 'Application Screen', thumbnail: undefined },
{ display_id: '2', id: '2', name: 'Application Screen 2', thumbnail: undefined },
{ display_id: '3', id: '3', name: 'Application Screen 3', thumbnail: undefined },
],
};
wrapper.setState(applicationScreenStateMock);
expect(wrapper.find(applicationTabCustomSelector)).toHaveLength(1);
expect(wrapper.find(screenTabCustomSelector)).toHaveLength(0);
});
it('should show `screen-tab` when source name is Entire screen', () => {
const wrapper = shallow(React.createElement(ScreenPicker));
const entireScreenStateMock = {
sources: [
{ display_id: '1', id: '1', name: 'Entire screen', thumbnail: undefined },
{ display_id: '2', id: '2', name: 'Screen 2', thumbnail: undefined },
{ display_id: '3', id: '3', name: 'screen 3', thumbnail: undefined },
],
};
wrapper.setState(entireScreenStateMock);
expect(wrapper.find(screenTabCustomSelector)).toHaveLength(1);
expect(wrapper.find(applicationTabCustomSelector)).toHaveLength(0);
});
it('should show `screen-tab` and `application-tab` when `isScreensAvailable` and `isApplicationsAvailable` is true', () => {
const wrapper = shallow(React.createElement(ScreenPicker));
const customState = {
sources: [
{ display_id: '1', id: '1', name: 'Entire screen', thumbnail: undefined },
{ display_id: '1', id: '1', name: 'Application screen', thumbnail: undefined },
],
};
wrapper.setState(customState);
expect(wrapper.find(applicationTabCustomSelector)).toHaveLength(1);
expect(wrapper.find(screenTabCustomSelector)).toHaveLength(1);
});
it('should show `error-message` when source is empty', () => {
const errorSelector = '.error-message';
const wrapper = shallow(React.createElement(ScreenPicker));
wrapper.setState({ sources: []});
expect(wrapper.find(errorSelector)).toHaveLength(1);
});
});
describe('`screen-picker-data` event', () => {
it('should call `screen-picker-data` when component is mounted', () => {
const onEventLabel = 'on';
const spy = jest.spyOn(ipcRenderer, onEventLabel);
shallow(React.createElement(ScreenPicker));
expect(spy).lastCalledWith(screenPickerDataLabel, expect.any(Function));
});
it('should remove listen `screen-picker-data` when component is unmounted', () => {
const removeListenerEventLabel = 'removeListener';
const spy = jest.spyOn(ipcRenderer, removeListenerEventLabel);
shallow(React.createElement(ScreenPicker)).unmount();
expect(spy).lastCalledWith(screenPickerDataLabel, expect.any(Function));
});
});
it('should call `ScreenPicker-window-border` event when component is mounted and is WindowsOS', () => {
const env = require('../src/common/env');
const spy = jest.spyOn(document.body.classList, 'add');
const expectedValue = 'ScreenPicker-window-border';
env.isWindowsOS = true;
shallow(React.createElement(ScreenPicker));
expect(spy).toBeCalledWith(expectedValue);
});
});

View File

@ -0,0 +1,72 @@
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,
};
});
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',
};
const spy = jest.spyOn(ipcRenderer, sendEventLabel);
const wrapper = shallow(React.createElement(ScreenSharingIndicator));
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));
});
});
});