fix(specs) Fix AutoUpdateManager specs

This commit is contained in:
Juan Tejada 2017-02-09 13:29:50 -08:00
parent ba464e9f21
commit c44324e636

View file

@ -6,6 +6,10 @@ describe "AutoUpdateManager", ->
@nylasIdentityId = null
@accounts = [{email_address: 'ben@nylas.com'},{email_address: 'mark@nylas.com'}]
@specMode = true
@databaseReader =
getJSONBlob: => {
id: @nylasIdentityId
}
@config =
set: jasmine.createSpy('config.set')
get: (key) =>
@ -18,7 +22,7 @@ describe "AutoUpdateManager", ->
describe "with attached commit version", ->
it "correctly sets the feedURL", ->
m = new AutoUpdateManager("3.222.1-abc", @config, @specMode)
m = new AutoUpdateManager("3.222.1-abc", @config, @specMode, @databaseReader)
spyOn(m, "setupAutoUpdater")
{query} = url.parse(m.feedURL, true)
@ -28,7 +32,7 @@ describe "AutoUpdateManager", ->
describe "with no attached commit", ->
it "correctly sets the feedURL", ->
m = new AutoUpdateManager("3.222.1", @config, @specMode)
m = new AutoUpdateManager("3.222.1", @config, @specMode, @databaseReader)
spyOn(m, "setupAutoUpdater")
{query} = url.parse(m.feedURL, true)
expect(query.arch).toBe process.arch
@ -37,7 +41,7 @@ describe "AutoUpdateManager", ->
describe "when an update identity is not present", ->
it "should use anonymous", ->
m = new AutoUpdateManager("3.222.1", @config, @specMode)
m = new AutoUpdateManager("3.222.1", @config, @specMode, @databaseReader)
spyOn(m, "setupAutoUpdater")
{query} = url.parse(m.feedURL, true)
expect(query.id).toEqual('anonymous')
@ -45,18 +49,18 @@ describe "AutoUpdateManager", ->
describe "when an update identity is already set", ->
it "should send it and not save any changes", ->
@nylasIdentityId = "test-nylas-id"
m = new AutoUpdateManager("3.222.1", @config, @specMode)
m = new AutoUpdateManager("3.222.1", @config, @specMode, @databaseReader)
spyOn(m, "setupAutoUpdater")
{query} = url.parse(m.feedURL, true)
expect(query.id).toEqual(@nylasIdentityId)
describe "when an update identity is added", ->
it "should update the feed URL", ->
m = new AutoUpdateManager("3.222.1", @config, @specMode)
m = new AutoUpdateManager("3.222.1", @config, @specMode, @databaseReader)
spyOn(m, "setupAutoUpdater")
{query} = url.parse(m.feedURL, true)
expect(query.id).toEqual('anonymous')
@nylasIdentityId = '1'
m._updateFeedURL()
m.updateFeedURL()
{query} = url.parse(m.feedURL, true)
expect(query.id).toEqual(@nylasIdentityId)