Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Mar 7, 2020
1 parent 62abcf5 commit ebef6aa
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/api/core/src/api/make.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MakerImpl extends MakerBase<any> {
defaultPlatforms = [];
}

type MakeTarget = IForgeResolvableMaker | MakerBase<any>;
type MakeTarget = IForgeResolvableMaker | MakerBase<any> | string;

function generateTargets(forgeConfig: ForgeConfig, overrideTargets?: MakeTarget[]) {
if (overrideTargets) {
Expand Down
31 changes: 31 additions & 0 deletions packages/api/core/test/fast/make_spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { expect } from 'chai';
import * as path from 'path';
import proxyquire from 'proxyquire';

import { MakeOptions } from '../../src/api';

describe('make', () => {
let make: (opts: MakeOptions) => Promise<any[]>;
beforeEach(() => {
const electronPath = path.resolve(__dirname, 'node_modules/electron');
make = proxyquire.noCallThru().load('../../src/api/make', {
'../util/electron-version': {
getElectronModulePath: () => Promise.resolve(electronPath),
getElectronVersion: () => Promise.resolve('1.0.0'),
},
}).default;
});
describe('overrideTargets inherits from forge config', () => {
it('passes config properly', async () => {
const results = await make({
arch: 'x64',
dir: path.resolve(__dirname, '..', 'fixture', 'app-with-custom-maker-config'),
overrideTargets: ['../custom-maker'],
platform: 'linux',
skipPackage: true,
});

expect(results[0].artifacts).to.deep.equal(['from config']);
});
});
});
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "test",
"config": {
"forge": {
"makers": [
{
"name": "../custom-maker",
"config": {
"artifactPath": "from config"
}
},
{
"name": "@electron-forge/non-existent-forge-maker"
}
]
}
},
"devDependencies": {
"electron": "^1.0.0"
}
}
20 changes: 20 additions & 0 deletions packages/api/core/test/fixture/custom-maker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ForgePlatform } from '@electron-forge/shared-types';
import MakerBase from '@electron-forge/maker-base';

interface Config {
artifactPath: string;
}

export default class Maker extends MakerBase<Config> {
name = 'custom-maker';

defaultPlatforms = [process.platform] as ForgePlatform[];

isSupportedOnCurrentPlatform() {
return true;
}

async make() {
return Promise.resolve([this.config.artifactPath || 'default']);
}
}

0 comments on commit ebef6aa

Please sign in to comment.