SymphonyElectron/spec/childWindowHandle.spec.ts
Kiran Niranjan 4d3455b3a4
SDA-3733 (Upgrade electron version to 19) (#1437)
* SDA-3733 - Update electron version to 19

* Remove electron-rebuild dependency

* Switch to node version 16.13.2

* Remove rebuild script

* Bump napi

* Use node 16.13.2

* remove @types dependency

* Bump node version for build-mac.sh

* Bump run-script-os and screen-share-indicator-frame

* updated electron and electron-builder

* Capture unhandled rejections

* Remove swift search

* Update to version 19

* Swift Shader is no longer part of 19 builds

* Update ci node version

* SDA-3733 - Bump electron version to 19.0.2
2022-06-14 14:00:20 +05:30

89 lines
1.9 KiB
TypeScript

import { handleChildWindow } from '../src/app/child-window-handler';
import { webContents } from './__mocks__/electron';
import anything = jasmine.anything;
const getMainWindow = {
isDestroyed: jest.fn(() => false),
getBounds: jest.fn(() => {
return {
x: 11,
y: 22,
};
}),
isAlwaysOnTop: jest.fn(() => true),
setMenuBarVisibility: jest.fn(),
setAlwaysOnTop: jest.fn(),
setFullScreenable: jest.fn(),
};
jest.mock('fs', () => ({
writeFile: jest.fn(),
existsSync: jest.fn(() => true),
readFileSync: jest.fn(() => '{"configVersion": "4.0.0"}'),
}));
jest.mock('electron-log');
jest.mock('../src/common/env', () => {
return {
isWindowsOS: true,
isLinux: false,
isMac: false,
};
});
jest.mock('../src/app/window-utils', () => {
return {
injectStyles: jest.fn(),
preventWindowNavigation: jest.fn(),
};
});
jest.mock('../src/app/window-handler', () => {
return {
windowHandler: {
url: 'https://test.symphony.com',
getMainWindow: jest.fn(() => {
return getMainWindow;
}),
openUrlInDefaultBrowser: jest.fn(),
addWindow: jest.fn(),
},
};
});
jest.mock('../src/app/window-actions', () => {
return {
monitorWindowActions: jest.fn(),
};
});
jest.mock('../src/common/logger', () => {
return {
logger: {
setLoggerWindow: jest.fn(),
error: jest.fn(),
warn: jest.fn(),
info: jest.fn(),
verbose: jest.fn(),
debug: jest.fn(),
silly: jest.fn(),
},
};
});
describe('child window handle', () => {
it('should set open window handler', () => {
const spy = jest.spyOn(webContents, 'setWindowOpenHandler');
handleChildWindow(webContents as any);
expect(spy).toBeCalledWith(expect.any(Function));
});
it('should trigger did-create-window', () => {
const spy = jest.spyOn(webContents, 'on');
handleChildWindow(webContents as any);
expect(spy).toBeCalledWith('did-create-window', anything());
});
});