Files
electron/spec/api-auto-updater-spec.ts
trop[bot] a3022df30f build: fix code-signing for MacOS x64 tests (#50072)
* fix: code-sign binaries for notification tests

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* test: remove redundent feedURL test

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* test: move squirrel feed tests to api-autoupdater

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* fix: fix SQRLShipItRequest.JSONKeyPathsByPropertyKey mappings

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* Revert "fix: fix SQRLShipItRequest.JSONKeyPathsByPropertyKey mappings"

This reverts commit 5ad9892a67.

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* test: unsign tests requiring no signed app

Co-authored-by: Keeley Hammond <khammond@slack-corp.com>

* fixup! fix: fix SQRLShipItRequest.JSONKeyPathsByPropertyKey mappings

chore: fix patch shear

---------

Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com>
Co-authored-by: Keeley Hammond <khammond@slack-corp.com>
Co-authored-by: Charles Kerr <charles@charleskerr.com>
2026-03-05 10:27:29 +01:00

70 lines
2.6 KiB
TypeScript

import { autoUpdater } from 'electron/main';
import { expect } from 'chai';
import { once } from 'node:events';
import { ifit, ifdescribe } from './lib/spec-helpers';
ifdescribe(!process.mas)('autoUpdater module', function () {
describe('checkForUpdates', function () {
ifit(process.platform === 'win32')('emits an error on Windows if the feed URL is not set', async function () {
const errorEvent = once(autoUpdater, 'error') as Promise<[Error]>;
autoUpdater.setFeedURL({ url: '' });
autoUpdater.checkForUpdates();
const [error] = await errorEvent;
expect(error.message).to.equal('Update URL is not set');
});
});
describe('getFeedURL', () => {
it('returns an empty string by default', () => {
expect(autoUpdater.getFeedURL()).to.equal('');
});
ifit(process.platform === 'win32')('correctly fetches the previously set FeedURL', function () {
const updateURL = 'https://fake-update.electron.io';
autoUpdater.setFeedURL({ url: updateURL });
expect(autoUpdater.getFeedURL()).to.equal(updateURL);
});
});
describe('setFeedURL', function () {
ifdescribe(process.platform === 'win32' || process.platform === 'darwin')('on Mac or Windows', () => {
it('sets url successfully using old (url, headers) syntax', () => {
const url = 'http://electronjs.org';
try {
(autoUpdater.setFeedURL as any)(url, { header: 'val' });
} catch { /* ignore */ }
expect(autoUpdater.getFeedURL()).to.equal(url);
});
it('throws if no url is provided when using the old style', () => {
expect(() => (autoUpdater.setFeedURL as any)()).to.throw('Expected an options object with a \'url\' property to be provided');
});
it('sets url successfully using new ({ url }) syntax', () => {
const url = 'http://mymagicurl.local';
try {
autoUpdater.setFeedURL({ url });
} catch { /* ignore */ }
expect(autoUpdater.getFeedURL()).to.equal(url);
});
it('throws if no url is provided when using the new style', () => {
expect(() => autoUpdater.setFeedURL({ noUrl: 'lol' } as any)
).to.throw('Expected options object to contain a \'url\' string property in setFeedUrl call');
});
});
});
describe('quitAndInstall', () => {
ifit(process.platform === 'win32')('emits an error on Windows when no update is available', async function () {
const errorEvent = once(autoUpdater, 'error') as Promise<[Error]>;
autoUpdater.quitAndInstall();
const [error] = await errorEvent;
expect(error.message).to.equal('No update available, can\'t quit and install');
});
});
});