mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
Add isEnabled function to AutoUpdateManager
This commit is contained in:
@@ -63,6 +63,38 @@ describe('AutoUpdateManager (renderer)', () => {
|
||||
})
|
||||
})
|
||||
|
||||
describe('::isEnabled', () => {
|
||||
let platform, releaseChannel
|
||||
it('returns true on OS X and Windows, when in stable', () => {
|
||||
spyOn(autoUpdateManager, 'getPlatform').andCallFake(() => platform)
|
||||
spyOn(autoUpdateManager, 'getReleaseChannel').andCallFake(() => releaseChannel)
|
||||
|
||||
platform = 'win32'
|
||||
releaseChannel = 'stable'
|
||||
expect(autoUpdateManager.isEnabled()).toBe(true)
|
||||
|
||||
platform = 'win32'
|
||||
releaseChannel = 'dev'
|
||||
expect(autoUpdateManager.isEnabled()).toBe(false)
|
||||
|
||||
platform = 'darwin'
|
||||
releaseChannel = 'stable'
|
||||
expect(autoUpdateManager.isEnabled()).toBe(true)
|
||||
|
||||
platform = 'darwin'
|
||||
releaseChannel = 'dev'
|
||||
expect(autoUpdateManager.isEnabled()).toBe(false)
|
||||
|
||||
platform = 'linux'
|
||||
releaseChannel = 'stable'
|
||||
expect(autoUpdateManager.isEnabled()).toBe(false)
|
||||
|
||||
platform = 'linux'
|
||||
releaseChannel = 'dev'
|
||||
expect(autoUpdateManager.isEnabled()).toBe(false)
|
||||
})
|
||||
})
|
||||
|
||||
describe('::dispose', () => {
|
||||
it('subscribes to "update-not-available" event', () => {
|
||||
const spy = jasmine.createSpy('spy')
|
||||
|
||||
@@ -31,6 +31,18 @@ export default class AutoUpdateManager {
|
||||
this.emitter.dispose()
|
||||
}
|
||||
|
||||
checkForUpdate () {
|
||||
ipcRenderer.send('check-for-update')
|
||||
}
|
||||
|
||||
quitAndInstallUpdate () {
|
||||
ipcRenderer.send('install-update')
|
||||
}
|
||||
|
||||
isEnabled () {
|
||||
return this.getReleaseChannel() == 'stable' && (this.getPlatform() === 'darwin' || this.getPlatform() === 'win32')
|
||||
}
|
||||
|
||||
onDidBeginCheckingForUpdate (callback) {
|
||||
return this.emitter.on('did-begin-checking-for-update', callback)
|
||||
}
|
||||
@@ -47,7 +59,18 @@ export default class AutoUpdateManager {
|
||||
return this.emitter.on('update-not-available', callback)
|
||||
}
|
||||
|
||||
checkForUpdate () {
|
||||
ipcRenderer.send('check-for-update')
|
||||
getPlatform () {
|
||||
return process.platform
|
||||
}
|
||||
|
||||
// TODO: We should move this into atom env or something.
|
||||
getReleaseChannel () {
|
||||
let version = atom.getVersion()
|
||||
if (version.indexOf('beta') > -1) {
|
||||
return 'beta'
|
||||
} else if (version.indexOf('dev') > -1) {
|
||||
return 'dev'
|
||||
}
|
||||
return 'stable'
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user