From a20b379f26f931cf1bed80f5264e9985e7386b23 Mon Sep 17 00:00:00 2001 From: Samuel Attard Date: Fri, 16 Feb 2018 16:02:10 +1100 Subject: [PATCH] fix windows tests --- .../api/auto-updater/auto-updater-win.js | 12 ++++-- spec/api-auto-updater-spec.js | 38 +++++++++---------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/lib/browser/api/auto-updater/auto-updater-win.js b/lib/browser/api/auto-updater/auto-updater-win.js index 97e6ef002842..7fead4aabb4a 100644 --- a/lib/browser/api/auto-updater/auto-updater-win.js +++ b/lib/browser/api/auto-updater/auto-updater-win.js @@ -19,12 +19,16 @@ class AutoUpdater extends EventEmitter { setFeedURL (options) { let updateURL - if (typeof options === 'string') { + if (typeof options === 'object') { + if (typeof options.url === 'string') { + updateURL = options.url + } else { + throw new Error('Expected options object to contain a \'url\' string property in setFeedUrl call') + } + } else if (typeof options === 'string') { updateURL = options - } else if (typeof options === 'object' && typeof options.url === 'string') { - updateURL = options.url } else { - throw new Error('Expected options.url to be a string but none was provided') + throw new Error('Expected an options object with a \'url\' property to be provided') } this.updateURL = updateURL } diff --git a/spec/api-auto-updater-spec.js b/spec/api-auto-updater-spec.js index baa8835600dd..c2a26326135e 100644 --- a/spec/api-auto-updater-spec.js +++ b/spec/api-auto-updater-spec.js @@ -29,6 +29,25 @@ describe('autoUpdater module', function () { }) }) + describe('getFeedURL', function () { + it('returns a falsey value by default', function () { + assert.ok(!autoUpdater.getFeedURL()) + }) + + it('correctly fetches the previously set FeedURL', function (done) { + if (process.platform !== 'win32') { + // FIXME(alexeykuzmin): Skip the test. + // this.skip() + return done() + } + + const updateURL = 'https://fake-update.electron.io' + autoUpdater.setFeedURL(updateURL) + assert.equal(autoUpdater.getFeedURL(), updateURL) + done() + }) + }) + describe('setFeedURL', function () { describe('on Mac or Windows', () => { const noThrow = (fn) => { @@ -106,25 +125,6 @@ describe('autoUpdater module', function () { }) }) - describe('getFeedURL', function () { - it('returns a falsey value by default', function () { - assert.ok(!autoUpdater.getFeedURL()) - }) - - it('correctly fetches the previously set FeedURL', function (done) { - if (process.platform !== 'win32') { - // FIXME(alexeykuzmin): Skip the test. - // this.skip() - return done() - } - - const updateURL = 'https://fake-update.electron.io' - autoUpdater.setFeedURL(updateURL) - assert.equal(autoUpdater.getFeedURL(), updateURL) - done() - }) - }) - describe('quitAndInstall', function () { it('emits an error on Windows when no update is available', function (done) { if (process.platform !== 'win32') {