Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert auto-update-manager-spec to ES6 #3146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
62 changes: 0 additions & 62 deletions spec/auto-update-manager-spec.coffee

This file was deleted.

80 changes: 80 additions & 0 deletions spec/auto-update-manager-spec.es6
Original file line number Diff line number Diff line change
@@ -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: '[email protected]'}, {email_address: '[email protected]'}];
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);
})
);
});