Typescript - Remove unwanted checks in protocol handler and add test cases

This commit is contained in:
Kiran Niranjan
2019-04-02 10:57:26 +05:30
parent 05b52380ed
commit 7ee09ab787
2 changed files with 20 additions and 6 deletions
+20
View File
@@ -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();
});
});