2019-03-25 03:26:08 -05:00
|
|
|
import { handleChildWindow } from '../src/app/child-window-handler';
|
2021-10-20 02:40:58 -05:00
|
|
|
import { webContents } from './__mocks__/electron';
|
|
|
|
import anything = jasmine.anything;
|
2019-03-25 03:26:08 -05:00
|
|
|
|
|
|
|
const getMainWindow = {
|
2021-01-29 00:25:40 -06:00
|
|
|
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(),
|
2019-03-25 03:26:08 -05:00
|
|
|
};
|
|
|
|
|
2022-06-14 03:30:20 -05:00
|
|
|
jest.mock('fs', () => ({
|
|
|
|
writeFile: jest.fn(),
|
|
|
|
existsSync: jest.fn(() => true),
|
|
|
|
readFileSync: jest.fn(() => '{"configVersion": "4.0.0"}'),
|
|
|
|
}));
|
|
|
|
|
2019-03-25 03:26:08 -05:00
|
|
|
jest.mock('../src/common/env', () => {
|
2021-01-29 00:25:40 -06:00
|
|
|
return {
|
|
|
|
isWindowsOS: true,
|
|
|
|
isLinux: false,
|
|
|
|
isMac: false,
|
|
|
|
};
|
2019-03-25 03:26:08 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
jest.mock('../src/app/window-utils', () => {
|
2021-01-29 00:25:40 -06:00
|
|
|
return {
|
|
|
|
injectStyles: jest.fn(),
|
|
|
|
preventWindowNavigation: jest.fn(),
|
|
|
|
};
|
2019-03-25 03:26:08 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
jest.mock('../src/app/window-handler', () => {
|
2021-01-29 00:25:40 -06:00
|
|
|
return {
|
|
|
|
windowHandler: {
|
|
|
|
url: 'https://test.symphony.com',
|
|
|
|
getMainWindow: jest.fn(() => {
|
|
|
|
return getMainWindow;
|
|
|
|
}),
|
|
|
|
openUrlInDefaultBrowser: jest.fn(),
|
|
|
|
addWindow: jest.fn(),
|
|
|
|
},
|
|
|
|
};
|
2019-03-25 03:26:08 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
jest.mock('../src/app/window-actions', () => {
|
2021-01-29 00:25:40 -06:00
|
|
|
return {
|
|
|
|
monitorWindowActions: jest.fn(),
|
|
|
|
};
|
2019-03-25 03:26:08 -05:00
|
|
|
});
|
|
|
|
|
2023-09-21 07:41:26 -05:00
|
|
|
jest.mock('../src/app/auto-update-handler', () => {
|
|
|
|
return {};
|
|
|
|
});
|
|
|
|
|
2024-02-19 03:41:50 -06:00
|
|
|
jest.mock('../src/app/config-handler', () => {
|
|
|
|
return {};
|
|
|
|
});
|
|
|
|
|
2019-03-25 03:26:08 -05:00
|
|
|
describe('child window handle', () => {
|
2021-10-20 02:40:58 -05:00
|
|
|
it('should set open window handler', () => {
|
|
|
|
const spy = jest.spyOn(webContents, 'setWindowOpenHandler');
|
2019-03-25 03:26:08 -05:00
|
|
|
|
2021-10-20 02:40:58 -05:00
|
|
|
handleChildWindow(webContents as any);
|
|
|
|
expect(spy).toBeCalledWith(expect.any(Function));
|
2021-01-29 00:25:40 -06:00
|
|
|
});
|
|
|
|
|
2021-10-20 02:40:58 -05:00
|
|
|
it('should trigger did-create-window', () => {
|
|
|
|
const spy = jest.spyOn(webContents, 'on');
|
|
|
|
handleChildWindow(webContents as any);
|
|
|
|
expect(spy).toBeCalledWith('did-create-window', anything());
|
2021-01-29 00:25:40 -06:00
|
|
|
});
|
2019-03-25 03:26:08 -05:00
|
|
|
});
|