minifix(GUI): don't call shell.openExternal if resource is undefined (#622)

This PR fixes an uncaught error being thrown when
`OSOpenExternalService.open()` is called with an undefined value.

Signed-off-by: Juan Cruz Viotti <jviottidc@gmail.com>
This commit is contained in:
Juan Cruz Viotti 2016-08-04 11:02:20 -04:00 committed by GitHub
parent c31b45200d
commit 7fa4178161
2 changed files with 14 additions and 1 deletions

View File

@ -30,6 +30,10 @@ module.exports = function() {
* @example
* OSOpenExternalService.open('https://www.google.com');
*/
this.open = electron.shell.openExternal;
this.open = (url) => {
if (url) {
electron.shell.openExternal(url);
}
};
};

View File

@ -52,6 +52,15 @@ describe('Browser: OSOpenExternal', function() {
shellExternalStub.restore();
});
it('should not call Electron shell.openExternal if the attribute value is not defined', function() {
const shellExternalStub = m.sinon.stub(electron.shell, 'openExternal');
const element = $compile('<span os-open-external>Resin.io</span>')($rootScope);
element.triggerHandler('click');
$rootScope.$digest();
m.chai.expect(shellExternalStub).to.not.have.been.called;
shellExternalStub.restore();
});
});
});