|
@@ -29,8 +29,65 @@ 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) => {
|
|
|
+ try { fn() } catch (err) {}
|
|
|
+ }
|
|
|
+
|
|
|
+ before(function () {
|
|
|
+ if (process.platform !== 'win32' && process.platform !== 'darwin') {
|
|
|
+ this.skip()
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ it('sets url successfully using old (url, headers) syntax', () => {
|
|
|
+ noThrow(() => autoUpdater.setFeedURL('http://electronjs.org', { header: 'val' }))
|
|
|
+ assert.equal(autoUpdater.getFeedURL(), 'http://electronjs.org')
|
|
|
+ })
|
|
|
+
|
|
|
+ it('throws if no url is provided when using the old style', () => {
|
|
|
+ assert.throws(
|
|
|
+ () => autoUpdater.setFeedURL(),
|
|
|
+ err => err.message.includes('Expected an options object with a \'url\' property to be provided') // eslint-disable-line
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
+ it('sets url successfully using new ({ url }) syntax', () => {
|
|
|
+ noThrow(() => autoUpdater.setFeedURL({ url: 'http://mymagicurl.local' }))
|
|
|
+ assert.equal(autoUpdater.getFeedURL(), 'http://mymagicurl.local')
|
|
|
+ })
|
|
|
+
|
|
|
+ it('throws if no url is provided when using the new style', () => {
|
|
|
+ assert.throws(
|
|
|
+ () => autoUpdater.setFeedURL({ noUrl: 'lol' }),
|
|
|
+ err => err.message.includes('Expected options object to contain a \'url\' string property in setFeedUrl call') // eslint-disable-line
|
|
|
+ )
|
|
|
+ })
|
|
|
+ })
|
|
|
+
|
|
|
describe('on Mac', function () {
|
|
|
+ const isServerTypeError = (err) => err.message.includes('Expected serverType to be \'default\' or \'json\'')
|
|
|
+
|
|
|
before(function () {
|
|
|
if (process.platform !== 'darwin') {
|
|
|
this.skip()
|
|
@@ -44,25 +101,27 @@ describe('autoUpdater module', function () {
|
|
|
})
|
|
|
autoUpdater.setFeedURL('')
|
|
|
})
|
|
|
- })
|
|
|
- })
|
|
|
|
|
|
- describe('getFeedURL', function () {
|
|
|
- it('returns a falsey value by default', function () {
|
|
|
- assert.ok(!autoUpdater.getFeedURL())
|
|
|
- })
|
|
|
+ it('does not throw if default is the serverType', () => {
|
|
|
+ assert.doesNotThrow(
|
|
|
+ () => autoUpdater.setFeedURL({ url: '', serverType: 'default' }),
|
|
|
+ isServerTypeError
|
|
|
+ )
|
|
|
+ })
|
|
|
|
|
|
- it('correctly fetches the previously set FeedURL', function (done) {
|
|
|
- if (process.platform !== 'win32') {
|
|
|
- // FIXME(alexeykuzmin): Skip the test.
|
|
|
- // this.skip()
|
|
|
- return done()
|
|
|
- }
|
|
|
+ it('does not throw if json is the serverType', () => {
|
|
|
+ assert.doesNotThrow(
|
|
|
+ () => autoUpdater.setFeedURL({ url: '', serverType: 'default' }),
|
|
|
+ isServerTypeError
|
|
|
+ )
|
|
|
+ })
|
|
|
|
|
|
- const updateURL = 'https://fake-update.electron.io'
|
|
|
- autoUpdater.setFeedURL(updateURL)
|
|
|
- assert.equal(autoUpdater.getFeedURL(), updateURL)
|
|
|
- done()
|
|
|
+ it('does throw if an unknown string is the serverType', () => {
|
|
|
+ assert.throws(
|
|
|
+ () => autoUpdater.setFeedURL({ url: '', serverType: 'weow' }),
|
|
|
+ isServerTypeError
|
|
|
+ )
|
|
|
+ })
|
|
|
})
|
|
|
})
|
|
|
|