Mailspring/app/spec/auto-update-manager-spec.coffee

44 lines
1.7 KiB
CoffeeScript
Raw Normal View History

AutoUpdateManager = require('../src/browser/auto-update-manager').default
url = require 'url'
describe "AutoUpdateManager", ->
beforeEach ->
@nylasIdentityId = null
@specMode = true
@config =
set: jasmine.createSpy('config.set')
get: (key) =>
2017-08-27 06:13:34 +08:00
if key is 'identity.id'
return @nylasIdentityId
2017-01-16 09:06:23 +08:00
if key is 'env'
return 'production'
onDidChange: (key, callback) =>
callback()
describe "with attached commit version", ->
it "correctly sets the feedURL", ->
2017-07-05 14:32:52 +08:00
m = new AutoUpdateManager("3.222.1-abc", @config, @specMode)
spyOn(m, "setupAutoUpdater")
expect(m.feedURL).toEqual('https://updates.getmailspring.com/check/darwin/x64/3.222.1-abc/anonymous/stable')
describe "with no attached commit", ->
it "correctly sets the feedURL", ->
2017-07-05 14:32:52 +08:00
m = new AutoUpdateManager("3.222.1", @config, @specMode)
spyOn(m, "setupAutoUpdater")
expect(m.feedURL).toEqual('https://updates.getmailspring.com/check/darwin/x64/3.222.1/anonymous/stable')
describe "when an update identity is already set", ->
it "should send it and not save any changes", ->
@nylasIdentityId = "test-nylas-id"
2017-07-05 14:32:52 +08:00
m = new AutoUpdateManager("3.222.1", @config, @specMode)
expect(m.feedURL).toEqual('https://updates.getmailspring.com/check/darwin/x64/3.222.1/test-nylas-id/stable')
describe "when an update identity is added", ->
it "should update the feed URL", ->
2017-07-05 14:32:52 +08:00
m = new AutoUpdateManager("3.222.1", @config, @specMode)
spyOn(m, "setupAutoUpdater")
2017-08-27 06:13:34 +08:00
expect(m.feedURL.includes('anonymous')).toEqual(true);
@nylasIdentityId = 'test-nylas-id'
2017-02-10 05:29:50 +08:00
m.updateFeedURL()
2017-08-27 06:13:34 +08:00
expect(m.feedURL.includes(@nylasIdentityId)).toEqual(true);