2016-03-25 19:57:49 +00:00
|
|
|
const assert = require('assert')
|
|
|
|
const autoUpdater = require('electron').remote.autoUpdater
|
|
|
|
const ipcRenderer = require('electron').ipcRenderer
|
2016-02-03 20:53:56 +00:00
|
|
|
|
2016-02-16 03:00:36 +00:00
|
|
|
// Skip autoUpdater tests in MAS build.
|
2016-03-25 19:57:49 +00:00
|
|
|
if (!process.mas) {
|
|
|
|
describe('autoUpdater module', function () {
|
|
|
|
describe('checkForUpdates', function () {
|
|
|
|
it('emits an error on Windows when called the feed URL is not set', function (done) {
|
|
|
|
if (process.platform !== 'win32') {
|
|
|
|
return done()
|
|
|
|
}
|
2016-02-16 03:00:36 +00:00
|
|
|
|
2016-03-25 19:57:49 +00:00
|
|
|
ipcRenderer.once('auto-updater-error', function (event, message) {
|
|
|
|
assert.equal(message, 'Update URL is not set')
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
autoUpdater.setFeedURL('')
|
|
|
|
autoUpdater.checkForUpdates()
|
|
|
|
})
|
|
|
|
})
|
2016-02-03 20:53:56 +00:00
|
|
|
|
2016-03-25 19:57:49 +00:00
|
|
|
describe('setFeedURL', function () {
|
2016-06-18 13:26:26 +00:00
|
|
|
it('emits an error on macOS when the application is unsigned', function (done) {
|
2016-03-25 19:57:49 +00:00
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
return done()
|
|
|
|
}
|
2016-02-03 20:53:56 +00:00
|
|
|
|
2016-03-25 19:57:49 +00:00
|
|
|
ipcRenderer.once('auto-updater-error', function (event, message) {
|
|
|
|
assert.equal(message, 'Could not get code signature for running application')
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
autoUpdater.setFeedURL('')
|
|
|
|
})
|
|
|
|
})
|
2016-07-14 22:13:41 +00:00
|
|
|
|
|
|
|
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') {
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
|
|
|
|
const updateURL = 'https://fake-update.electron.io'
|
|
|
|
autoUpdater.setFeedURL(updateURL)
|
|
|
|
assert.equal(autoUpdater.getFeedURL(), updateURL)
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
})
|
2016-08-08 20:12:39 +00:00
|
|
|
|
|
|
|
describe('quitAndInstall', function () {
|
|
|
|
it('emits an error on Windows when no update is available', function (done) {
|
|
|
|
if (process.platform !== 'win32') {
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
|
|
|
|
ipcRenderer.once('auto-updater-error', function (event, message) {
|
|
|
|
assert.equal(message, 'No update available, can\'t quit and install')
|
|
|
|
done()
|
|
|
|
})
|
|
|
|
autoUpdater.quitAndInstall()
|
|
|
|
})
|
|
|
|
})
|
2016-03-25 19:57:49 +00:00
|
|
|
})
|
|
|
|
}
|