2017-09-28 15:09:55 +08:00
|
|
|
AutoUpdateManager = require('../src/browser/autoupdate-manager').default
|
2015-10-04 05:45:39 +08:00
|
|
|
url = require 'url'
|
2015-06-12 03:08:47 +08:00
|
|
|
|
|
|
|
describe "AutoUpdateManager", ->
|
|
|
|
beforeEach ->
|
2016-06-03 09:56:03 +08:00
|
|
|
@nylasIdentityId = null
|
2015-11-03 03:56:11 +08:00
|
|
|
@specMode = true
|
2015-10-04 05:45:39 +08:00
|
|
|
@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'
|
2017-01-16 06:10:16 +08:00
|
|
|
return 'production'
|
2016-08-19 04:17:40 +08:00
|
|
|
onDidChange: (key, callback) =>
|
|
|
|
callback()
|
2015-06-12 03:08:47 +08:00
|
|
|
|
|
|
|
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)
|
2015-10-04 05:45:39 +08:00
|
|
|
spyOn(m, "setupAutoUpdater")
|
2017-09-06 04:37:40 +08:00
|
|
|
expect(m.feedURL).toEqual('https://updates.getmailspring.com/check/darwin/x64/3.222.1-abc/anonymous/stable')
|
2015-06-12 03:08:47 +08:00
|
|
|
|
2015-10-04 05:45:39 +08:00
|
|
|
describe "with no attached commit", ->
|
2015-06-12 03:08:47 +08:00
|
|
|
it "correctly sets the feedURL", ->
|
2017-07-05 14:32:52 +08:00
|
|
|
m = new AutoUpdateManager("3.222.1", @config, @specMode)
|
2015-10-04 05:45:39 +08:00
|
|
|
spyOn(m, "setupAutoUpdater")
|
2017-09-06 04:37:40 +08:00
|
|
|
expect(m.feedURL).toEqual('https://updates.getmailspring.com/check/darwin/x64/3.222.1/anonymous/stable')
|
2015-10-04 05:45:39 +08:00
|
|
|
|
|
|
|
describe "when an update identity is already set", ->
|
|
|
|
it "should send it and not save any changes", ->
|
2016-06-03 09:56:03 +08:00
|
|
|
@nylasIdentityId = "test-nylas-id"
|
2017-07-05 14:32:52 +08:00
|
|
|
m = new AutoUpdateManager("3.222.1", @config, @specMode)
|
2017-09-06 04:37:40 +08:00
|
|
|
expect(m.feedURL).toEqual('https://updates.getmailspring.com/check/darwin/x64/3.222.1/test-nylas-id/stable')
|
2016-08-19 04:17:40 +08:00
|
|
|
|
|
|
|
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)
|
2016-08-19 04:17:40 +08:00
|
|
|
spyOn(m, "setupAutoUpdater")
|
2017-09-28 02:08:07 +08:00
|
|
|
expect(m.feedURL.includes('anonymous')).toEqual(true)
|
2017-08-27 06:13:34 +08:00
|
|
|
@nylasIdentityId = 'test-nylas-id'
|
2017-02-10 05:29:50 +08:00
|
|
|
m.updateFeedURL()
|
2017-09-28 02:08:07 +08:00
|
|
|
expect(m.feedURL.includes(@nylasIdentityId)).toEqual(true)
|