@tywalk/pcf-helper
Version:
Command line helper for building and publishing PCF controls to Dataverse.
70 lines (69 loc) • 2.7 kB
JavaScript
;
/// <reference types="jest" />
/// <reference types="node" />
Object.defineProperty(exports, "__esModule", { value: true });
const child_process_1 = require("child_process");
const package_json_1 = require("../package.json");
const buildBeforeAll_1 = require("./setup/buildBeforeAll");
beforeAll(buildBeforeAll_1.buildBeforeAll, 60000);
test('session displays version', (done) => {
const task = (0, child_process_1.spawn)('node', ['./dist/bin/session.js', '-v']);
let output = '';
let stderrOutput = '';
task.stdout.on('data', (data) => {
output += data.toString();
});
task.stderr.on('data', (data) => {
stderrOutput += data.toString();
});
task.on('close', (code) => {
expect({ code, output, stderr: stderrOutput }).toMatchObject({ code: 0 });
expect(output).toContain(package_json_1.version);
done === null || done === void 0 ? void 0 : done();
});
}, 10000);
test('session errors if no/wrong args are provided', (done) => {
const task = (0, child_process_1.spawn)('node', ['./dist/bin/session.js', '-e']);
let output = '';
let stderrOutput = '';
task.stdout.on('data', (data) => {
output += data.toString();
});
task.stderr.on('data', (data) => {
stderrOutput += data.toString();
});
task.on('close', (code) => {
expect({ code, output, stderr: stderrOutput }).toMatchObject({ code: 1 });
done === null || done === void 0 ? void 0 : done();
});
}, 10000);
test('session errors if path does not exist', (done) => {
const task = (0, child_process_1.spawn)('node', ['./dist/bin/session.js', '-p', '/path/that/does/not/exist']);
let output = '';
let stderrOutput = '';
task.stdout.on('data', (data) => {
output += data.toString();
});
task.stderr.on('data', (data) => {
stderrOutput += data.toString();
});
task.on('close', (code) => {
expect({ code, output, stderr: stderrOutput }).toMatchObject({ code: 1 });
done === null || done === void 0 ? void 0 : done();
});
}, 10000);
test('session errors when watch retry flag is used without watch', (done) => {
const task = (0, child_process_1.spawn)('node', ['./dist/bin/session.js', '--watch-retry', 'false']);
let output = '';
let stderrOutput = '';
task.stdout.on('data', (data) => {
output += data.toString();
});
task.stderr.on('data', (data) => {
stderrOutput += data.toString();
});
task.on('close', (code) => {
expect({ code, output, stderr: stderrOutput }).toMatchObject({ code: 1 });
done === null || done === void 0 ? void 0 : done();
});
}, 10000);