diff --git a/lib/gui/os/open-external/services/open-external.js b/lib/gui/os/open-external/services/open-external.js index 1b9f5e92..915fc888 100644 --- a/lib/gui/os/open-external/services/open-external.js +++ b/lib/gui/os/open-external/services/open-external.js @@ -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); + } + }; }; diff --git a/tests/gui/os/open-external.spec.js b/tests/gui/os/open-external.spec.js index ef793590..dc173db8 100644 --- a/tests/gui/os/open-external.spec.js +++ b/tests/gui/os/open-external.spec.js @@ -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('Resin.io')($rootScope); + element.triggerHandler('click'); + $rootScope.$digest(); + m.chai.expect(shellExternalStub).to.not.have.been.called; + shellExternalStub.restore(); + }); + }); });