Skip to content

Commit

Permalink
spec: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MarshallOfSound committed Sep 25, 2024
1 parent 83291e7 commit 28c89e2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions packages/plugin/local-electron/test/LocalElectronPlugin_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import { LocalElectronPlugin } from '../src/LocalElectronPlugin';

describe('LocalElectronPlugin', () => {
describe('start logic', () => {
const fakeForgeConfig = {} as ResolvedForgeConfig;

before(() => {
delete process.env.ELECTRON_OVERRIDE_DIST_PATH;
});
Expand All @@ -20,30 +22,30 @@ describe('LocalElectronPlugin', () => {
it('should set ELECTRON_OVERRIDE_DIST_PATH when enabled', async () => {
expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal(undefined);
const p = new LocalElectronPlugin({ electronPath: 'test/foo' });
await p.startLogic();
await p.getHooks().preStart?.(fakeForgeConfig);
expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal('test/foo');
});

it('should not set ELECTRON_OVERRIDE_DIST_PATH when disabled', async () => {
expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal(undefined);
const p = new LocalElectronPlugin({ enabled: false, electronPath: 'test/foo' });
await p.startLogic();
await p.getHooks().preStart?.(fakeForgeConfig);
expect(process.env.ELECTRON_OVERRIDE_DIST_PATH).to.equal(undefined);
});

it("should throw an error if platforms don't match", async () => {
const p = new LocalElectronPlugin({ electronPath: 'test/bar', electronPlatform: 'wut' });
await expect(p.startLogic()).to.eventually.be.rejectedWith(
await expect(p.getHooks().preStart?.(fakeForgeConfig)).to.eventually.be.rejectedWith(
`Can not use local Electron version, required platform "${process.platform}" but local platform is "wut"`
);
});

it('should always return false', async () => {
let p = new LocalElectronPlugin({ electronPath: 'test/bar' });
expect(await p.startLogic()).to.equal(false);
expect(await p.getHooks().preStart?.(fakeForgeConfig)).to.equal(false);

p = new LocalElectronPlugin({ enabled: false, electronPath: 'test/bar' });
expect(await p.startLogic()).to.equal(false);
expect(await p.getHooks().preStart?.(fakeForgeConfig)).to.equal(false);
});
});

Expand Down

0 comments on commit 28c89e2

Please sign in to comment.