From a60f3419686959a8f225bcfbc96fa0981b446e70 Mon Sep 17 00:00:00 2001 From: Kevin Sawicki Date: Thu, 2 Feb 2017 08:11:34 -0800 Subject: [PATCH] Add procotol client specs on Windows --- spec/api-app-spec.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/spec/api-app-spec.js b/spec/api-app-spec.js index cf25dde6e557..27e4003d7d41 100644 --- a/spec/api-app-spec.js +++ b/spec/api-app-spec.js @@ -403,4 +403,39 @@ describe('app module', function () { w.webContents.loadURL(secureUrl) }) }) + + describe('setAsDefaultProtocolClient(protocol, path, args)', () => { + if (process.platform !== 'win32') return + + const updateExe = path.resolve(path.dirname(process.execPath), '..', 'Update.exe') + const processStartArgs = [ + '--processStart', `"${path.basename(process.execPath)}"`, + '--process-start-args', `"--hidden"` + ] + + beforeEach(() => { + app.removeAsDefaultProtocolClient('elecron-test') + app.removeAsDefaultProtocolClient('elecron-test', updateExe, processStartArgs) + }) + + afterEach(() => { + app.removeAsDefaultProtocolClient('elecron-test') + assert.equal(app.isDefaultProtocolClient('electron-test'), false) + app.removeAsDefaultProtocolClient('elecron-test', updateExe, processStartArgs) + assert.equal(app.isDefaultProtocolClient('electron-test', updateExe, processStartArgs), false) + }) + + it('sets the app as the default protocol client', () => { + assert.equal(app.isDefaultProtocolClient('electron-test'), false) + app.setAsDefaultProtocolClient('electron-test') + assert.equal(app.isDefaultProtocolClient('electron-test'), true) + }) + + it('allows a custom path and args to be specified', () => { + assert.equal(app.isDefaultProtocolClient('electron-test', updateExe, processStartArgs), false) + app.setAsDefaultProtocolClient('electron-test', updateExe, processStartArgs) + assert.equal(app.isDefaultProtocolClient('electron-test', updateExe, processStartArgs), true) + assert.equal(app.isDefaultProtocolClient('electron-test'), false) + }) + }) })