2016-05-07 03:00:45 +08:00
|
|
|
AutoUpdateManager = require('../src/browser/auto-update-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) =>
|
|
|
|
if key is 'nylas.accounts'
|
|
|
|
return [{email_address: 'ben@nylas.com'},{email_address: 'mark@nylas.com'}]
|
2016-06-03 09:56:03 +08:00
|
|
|
if key is 'nylas.identity.id'
|
|
|
|
return @nylasIdentityId
|
2015-06-12 03:08:47 +08:00
|
|
|
|
|
|
|
describe "with attached commit version", ->
|
|
|
|
it "correctly sets the feedURL", ->
|
2015-11-03 03:56:11 +08:00
|
|
|
m = new AutoUpdateManager("3.222.1-abc", @config, @specMode)
|
2015-10-04 05:45:39 +08:00
|
|
|
spyOn(m, "setupAutoUpdater")
|
2015-06-12 03:08:47 +08:00
|
|
|
|
2015-11-24 14:09:17 +08:00
|
|
|
{query} = url.parse(m.feedURL, true)
|
2015-10-04 05:45:39 +08:00
|
|
|
expect(query.arch).toBe process.arch
|
|
|
|
expect(query.platform).toBe process.platform
|
|
|
|
expect(query.version).toBe "3.222.1-abc"
|
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", ->
|
2015-11-03 03:56:11 +08:00
|
|
|
m = new AutoUpdateManager("3.222.1", @config, @specMode)
|
2015-10-04 05:45:39 +08:00
|
|
|
spyOn(m, "setupAutoUpdater")
|
2015-11-24 14:09:17 +08:00
|
|
|
{query} = url.parse(m.feedURL, true)
|
2015-10-04 05:45:39 +08:00
|
|
|
expect(query.arch).toBe process.arch
|
|
|
|
expect(query.platform).toBe process.platform
|
|
|
|
expect(query.version).toBe "3.222.1"
|
|
|
|
|
|
|
|
describe "when an update identity is not present", ->
|
2016-06-03 09:56:03 +08:00
|
|
|
it "should use anonymous", ->
|
2015-11-03 03:56:11 +08:00
|
|
|
m = new AutoUpdateManager("3.222.1", @config, @specMode)
|
2015-10-04 05:45:39 +08:00
|
|
|
spyOn(m, "setupAutoUpdater")
|
2015-11-24 14:09:17 +08:00
|
|
|
{query} = url.parse(m.feedURL, true)
|
2016-06-03 09:56:03 +08:00
|
|
|
expect(query.id).toEqual('anonymous')
|
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"
|
2015-11-03 03:56:11 +08:00
|
|
|
m = new AutoUpdateManager("3.222.1", @config, @specMode)
|
2015-10-04 05:45:39 +08:00
|
|
|
spyOn(m, "setupAutoUpdater")
|
2015-11-24 14:09:17 +08:00
|
|
|
{query} = url.parse(m.feedURL, true)
|
2016-06-03 09:56:03 +08:00
|
|
|
expect(query.id).toEqual(@nylasIdentityId)
|