diff --git a/spec/protocolHandler.spec.ts b/spec/protocolHandler.spec.ts index 09b1efaa..fd811a54 100644 --- a/spec/protocolHandler.spec.ts +++ b/spec/protocolHandler.spec.ts @@ -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() }; diff --git a/src/app/protocol-handler.ts b/src/app/protocol-handler.ts index 6a8bc669..c198ad95 100644 --- a/src/app/protocol-handler.ts +++ b/src/app/protocol-handler.ts @@ -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);