mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
added more tests to increase coverage to 100 for protocol handler
This commit is contained in:
parent
7ee09ab787
commit
68efbfa0e8
@ -13,6 +13,7 @@ jest.mock('../src/common/utils', () => {
|
|||||||
jest.mock('../src/common/env', () => {
|
jest.mock('../src/common/env', () => {
|
||||||
return {
|
return {
|
||||||
isWindowsOS: false,
|
isWindowsOS: false,
|
||||||
|
isMac: true
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -41,6 +42,31 @@ describe('protocol handler', () => {
|
|||||||
expect(spy).toBeCalledWith(protocolAction, 'symphony://?userId=123456');
|
expect(spy).toBeCalledWith(protocolAction, 'symphony://?userId=123456');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('protocol activate should be called when uri is correct on macOS', () => {
|
||||||
|
const { activate } = require('../src/app/window-actions');
|
||||||
|
|
||||||
|
protocolHandlerInstance.preloadWebContents = { send: jest.fn() };
|
||||||
|
const uri: string = 'symphony://?userId=123456';
|
||||||
|
|
||||||
|
protocolHandlerInstance.sendProtocol(uri);
|
||||||
|
|
||||||
|
expect(activate).toBeCalledWith('main');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('protocol activate should not be called when uri is correct on non macOS', () => {
|
||||||
|
const env = require('../src/common/env');
|
||||||
|
env.isMac = false;
|
||||||
|
|
||||||
|
const { activate } = require('../src/app/window-actions');
|
||||||
|
|
||||||
|
protocolHandlerInstance.preloadWebContents = { send: jest.fn() };
|
||||||
|
const uri: string = 'symphony://?userId=123456';
|
||||||
|
|
||||||
|
protocolHandlerInstance.sendProtocol(uri);
|
||||||
|
|
||||||
|
expect(activate).not.toBeCalled();
|
||||||
|
});
|
||||||
|
|
||||||
it('protocol action not should be called when uri is incorrect', () => {
|
it('protocol action not should be called when uri is incorrect', () => {
|
||||||
protocolHandlerInstance.preloadWebContents = { send: jest.fn() };
|
protocolHandlerInstance.preloadWebContents = { send: jest.fn() };
|
||||||
|
|
||||||
|
@ -45,7 +45,9 @@ class ProtocolHandler {
|
|||||||
}
|
}
|
||||||
// This is needed for mac OS as it brings pop-outs to foreground
|
// This is needed for mac OS as it brings pop-outs to foreground
|
||||||
// (if it has been previously focused) instead of main window
|
// (if it has been previously focused) instead of main window
|
||||||
if (isMac) activate(apiName.mainWindowName);
|
if (isMac) {
|
||||||
|
activate(apiName.mainWindowName);
|
||||||
|
}
|
||||||
|
|
||||||
if (ProtocolHandler.isValidProtocolUri(uri)) {
|
if (ProtocolHandler.isValidProtocolUri(uri)) {
|
||||||
this.preloadWebContents.send('protocol-action', uri);
|
this.preloadWebContents.send('protocol-action', uri);
|
||||||
|
Loading…
Reference in New Issue
Block a user