mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-21 16:38:41 -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', () => {
|
||||
return {
|
||||
isWindowsOS: false,
|
||||
isMac: true
|
||||
};
|
||||
});
|
||||
|
||||
@ -41,6 +42,31 @@ describe('protocol handler', () => {
|
||||
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', () => {
|
||||
protocolHandlerInstance.preloadWebContents = { send: jest.fn() };
|
||||
|
||||
|
@ -45,7 +45,9 @@ class ProtocolHandler {
|
||||
}
|
||||
// This is needed for mac OS as it brings pop-outs to foreground
|
||||
// (if it has been previously focused) instead of main window
|
||||
if (isMac) activate(apiName.mainWindowName);
|
||||
if (isMac) {
|
||||
activate(apiName.mainWindowName);
|
||||
}
|
||||
|
||||
if (ProtocolHandler.isValidProtocolUri(uri)) {
|
||||
this.preloadWebContents.send('protocol-action', uri);
|
||||
|
Loading…
Reference in New Issue
Block a user