mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-11-21 16:38:41 -06:00
Typescript - Remove unwanted checks in protocol handler and add test cases
This commit is contained in:
parent
05b52380ed
commit
7ee09ab787
@ -72,4 +72,24 @@ describe('protocol handler', () => {
|
||||
expect(spy).toBeCalled();
|
||||
});
|
||||
|
||||
it('should invoke `sendProtocol` when `setPreloadWebContents` is called and protocolUri is valid', () => {
|
||||
protocolHandlerInstance.preloadWebContents = { send: jest.fn() };
|
||||
protocolHandlerInstance.protocolUri = 'symphony://?userId=123456';
|
||||
|
||||
const spy: jest.SpyInstance = jest.spyOn(protocolHandlerInstance, 'sendProtocol');
|
||||
|
||||
protocolHandlerInstance.setPreloadWebContents({ send: jest.fn() });
|
||||
expect(spy).toBeCalledWith('symphony://?userId=123456');
|
||||
});
|
||||
|
||||
it('should not invoke `sendProtocol` when `setPreloadWebContents` is called and protocolUri is invalid', () => {
|
||||
protocolHandlerInstance.preloadWebContents = { send: jest.fn() };
|
||||
protocolHandlerInstance.protocolUri = null;
|
||||
|
||||
const spy: jest.SpyInstance = jest.spyOn(protocolHandlerInstance, 'sendProtocol');
|
||||
|
||||
protocolHandlerInstance.setPreloadWebContents({ send: jest.fn() });
|
||||
expect(spy).not.toBeCalled();
|
||||
});
|
||||
|
||||
});
|
||||
|
@ -1,5 +1,3 @@
|
||||
import * as url from 'url';
|
||||
|
||||
import { apiName } from '../common/api-interface';
|
||||
import { isMac, isWindowsOS } from '../common/env';
|
||||
import { getCommandLineArgs } from '../common/utils';
|
||||
@ -62,10 +60,6 @@ class ProtocolHandler {
|
||||
public processArgv(argv?: string[]): void {
|
||||
const protocolUriFromArgv = getCommandLineArgs(argv || process.argv, protocol.SymphonyProtocol, false);
|
||||
if (isWindowsOS && protocolUriFromArgv) {
|
||||
const parsedURL = url.parse(protocolUriFromArgv);
|
||||
if (!parsedURL.protocol || !parsedURL.slashes) {
|
||||
return;
|
||||
}
|
||||
this.sendProtocol(protocolUriFromArgv, false);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user