diff --git a/spec/auto-update-manager-spec.coffee b/spec/auto-update-manager-spec.coffee deleted file mode 100644 index fbcfdf659d..0000000000 --- a/spec/auto-update-manager-spec.coffee +++ /dev/null @@ -1,62 +0,0 @@ -AutoUpdateManager = require('../src/browser/auto-update-manager').default -url = require 'url' - -describe "AutoUpdateManager", -> - beforeEach -> - @nylasIdentityId = null - @accounts = [{email_address: 'ben@nylas.com'},{email_address: 'mark@nylas.com'}] - @specMode = true - @config = - set: jasmine.createSpy('config.set') - get: (key) => - if key is 'nylas.accounts' - return @accounts - if key is 'nylas.identity.id' - return @nylasIdentityId - onDidChange: (key, callback) => - callback() - - describe "with attached commit version", -> - it "correctly sets the feedURL", -> - m = new AutoUpdateManager("3.222.1-abc", @config, @specMode) - spyOn(m, "setupAutoUpdater") - - {query} = url.parse(m.feedURL, true) - expect(query.arch).toBe process.arch - expect(query.platform).toBe process.platform - expect(query.version).toBe "3.222.1-abc" - - describe "with no attached commit", -> - it "correctly sets the feedURL", -> - m = new AutoUpdateManager("3.222.1", @config, @specMode) - spyOn(m, "setupAutoUpdater") - {query} = url.parse(m.feedURL, true) - 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", -> - it "should use anonymous", -> - m = new AutoUpdateManager("3.222.1", @config, @specMode) - spyOn(m, "setupAutoUpdater") - {query} = url.parse(m.feedURL, true) - expect(query.id).toEqual('anonymous') - - 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) - 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) - spyOn(m, "setupAutoUpdater") - {query} = url.parse(m.feedURL, true) - expect(query.id).toEqual('anonymous') - @nylasIdentityId = '1' - m._updateFeedURL() - {query} = url.parse(m.feedURL, true) - expect(query.id).toEqual(@nylasIdentityId) diff --git a/spec/auto-update-manager-spec.es6 b/spec/auto-update-manager-spec.es6 new file mode 100644 index 0000000000..6c15d86dc1 --- /dev/null +++ b/spec/auto-update-manager-spec.es6 @@ -0,0 +1,80 @@ +import url from 'url'; +import AutoUpdateManager from '../src/browser/auto-update-manager'; + +describe("AutoUpdateManager", function autoUpdateManager() { + beforeEach(() => { + this.nylasIdentityId = null; + this.accounts = [{email_address: 'ben@nylas.com'}, {email_address: 'mark@nylas.com'}]; + this.specMode = true; + this.config = { + set: jasmine.createSpy('config.set'), + get: key => { + if (key === 'nylas.accounts') { + return this.accounts; + } + if (key === 'nylas.identity.id') { + return this.nylasIdentityId; + } + return null; + }, + onDidChange: (key, callback) => { + return callback(); + }, + }; + }); + + describe("with attached commit version", () => + it("correctly sets the feedURL", () => { + const m = new AutoUpdateManager("3.222.1-abc", this.config, this.specMode); + spyOn(m, "setupAutoUpdater"); + + const {query} = url.parse(m.feedURL, true); + expect(query.arch).toBe(process.arch); + expect(query.platform).toBe(process.platform); + expect(query.version).toBe("3.222.1-abc"); + }) + ); + + describe("with no attached commit", () => + it("correctly sets the feedURL", () => { + const m = new AutoUpdateManager("3.222.1", this.config, this.specMode); + spyOn(m, "setupAutoUpdater"); + const {query} = url.parse(m.feedURL, true); + 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", () => + it("should use anonymous", () => { + const m = new AutoUpdateManager("3.222.1", this.config, this.specMode); + spyOn(m, "setupAutoUpdater"); + const {query} = url.parse(m.feedURL, true); + expect(query.id).toEqual('anonymous'); + }) + ); + + describe("when an update identity is already set", () => + it("should send it and not save any changes", () => { + this.nylasIdentityId = "test-nylas-id"; + const m = new AutoUpdateManager("3.222.1", this.config, this.specMode); + spyOn(m, "setupAutoUpdater"); + const {query} = url.parse(m.feedURL, true); + expect(query.id).toEqual(this.nylasIdentityId); + }) + ); + + describe("when an update identity is added", () => + it("should update the feed URL", () => { + const m = new AutoUpdateManager("3.222.1", this.config, this.specMode); + spyOn(m, "setupAutoUpdater"); + let {query} = url.parse(m.feedURL, true); + expect(query.id).toEqual('anonymous'); + this.nylasIdentityId = '1'; + m._updateFeedURL(); + ({query} = url.parse(m.feedURL, true)); + expect(query.id).toEqual(this.nylasIdentityId); + }) + ); +});