mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-27 02:23:28 +08:00
59 lines
2.1 KiB
TypeScript
59 lines
2.1 KiB
TypeScript
import AutoUpdateManager from '../src/browser/autoupdate-manager';
|
|
|
|
describe('AutoUpdateManager', function() {
|
|
beforeEach(function() {
|
|
this.mailspringIdentityId = null;
|
|
this.specMode = true;
|
|
this.config = {
|
|
set: jasmine.createSpy('config.set'),
|
|
get: key => {
|
|
if (key === 'identity.id') {
|
|
return this.mailspringIdentityId;
|
|
}
|
|
if (key === 'env') {
|
|
return 'production';
|
|
}
|
|
},
|
|
onDidChange: (key, callback) => {
|
|
return callback();
|
|
},
|
|
};
|
|
});
|
|
|
|
describe('with attached commit version', () =>
|
|
it('correctly sets the feedURL', function() {
|
|
const m = new AutoUpdateManager('3.222.1-abc', this.config, this.specMode);
|
|
spyOn(m, 'setupAutoUpdater');
|
|
expect(m.feedURL).toEqual(
|
|
'https://updates.getmailspring.com/check/' + process.platform + '/x64/3.222.1-abc/anonymous/stable'
|
|
);
|
|
}));
|
|
|
|
describe('with no attached commit', () =>
|
|
it('correctly sets the feedURL', function() {
|
|
const m = new AutoUpdateManager('3.222.1', this.config, this.specMode);
|
|
spyOn(m, 'setupAutoUpdater');
|
|
expect(m.feedURL).toEqual(
|
|
'https://updates.getmailspring.com/check/' + process.platform + '/x64/3.222.1/anonymous/stable'
|
|
);
|
|
}));
|
|
|
|
describe('when an update identity is already set', () =>
|
|
it('should send it and not save any changes', function() {
|
|
this.mailspringIdentityId = 'test-mailspring-id';
|
|
const m = new AutoUpdateManager('3.222.1', this.config, this.specMode);
|
|
expect(m.feedURL).toEqual(
|
|
'https://updates.getmailspring.com/check/' + process.platform + '/x64/3.222.1/test-mailspring-id/stable'
|
|
);
|
|
}));
|
|
|
|
describe('when an update identity is added', () =>
|
|
it('should update the feed URL', function() {
|
|
const m = new AutoUpdateManager('3.222.1', this.config, this.specMode);
|
|
spyOn(m, 'setupAutoUpdater');
|
|
expect(m.feedURL.includes('anonymous')).toEqual(true);
|
|
this.mailspringIdentityId = 'test-mailspring-id';
|
|
m.updateFeedURL();
|
|
expect(m.feedURL.includes(this.mailspringIdentityId)).toEqual(true);
|
|
}));
|
|
});
|