CityBEM-CityLayers-SaeedRay.../node_modules/electron-rebuild/lib/test/electron-locator.js

45 lines
2.0 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const fs = require("fs-extra");
const path = require("path");
const chai_1 = require("chai");
const cross_spawn_promise_1 = require("@malept/cross-spawn-promise");
const electron_locator_1 = require("../src/electron-locator");
// eslint-disable-next-line @typescript-eslint/no-var-requires
const testElectronRange = require(path.resolve(__dirname, '..', 'package.json')).devDependencies.electron;
function packageCommand(command, packageName) {
return cross_spawn_promise_1.spawn('npm', [command, '--no-save', packageName], {
cwd: path.resolve(__dirname, '..'),
stdio: 'ignore',
});
}
const install = packageCommand.bind(null, 'install');
const uninstall = packageCommand.bind(null, 'uninstall');
const testElectronCanBeFound = () => {
it('should return a valid path', async () => {
const electronPath = await electron_locator_1.locateElectronModule();
chai_1.expect(electronPath).to.be.a('string');
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
chai_1.expect(await fs.pathExists(electronPath)).to.be.equal(true);
});
};
describe('locateElectronModule', function () {
this.timeout(30 * 1000);
before(() => uninstall('electron'));
it('should return null when electron is not installed', async () => {
await fs.remove(path.resolve(__dirname, '..', 'node_modules', 'electron'));
chai_1.expect(await electron_locator_1.locateElectronModule()).to.be.equal(null);
});
describe('with electron-prebuilt installed', async () => {
before(() => install('electron-prebuilt'));
testElectronCanBeFound();
after(() => uninstall('electron-prebuilt'));
});
describe('with electron installed', async () => {
before(() => install(`electron@${testElectronRange}`));
testElectronCanBeFound();
after(() => uninstall('electron'));
});
after(() => install(`electron@${testElectronRange}`));
});
//# sourceMappingURL=electron-locator.js.map