Files
test-repo/tests/integration/__tests__/plugin-options.js
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

68 lines
1.5 KiB
JavaScript
Raw Normal View History

2025-10-09 22:00:33 +08:00
import { createTwoFilesPatch } from "diff";
2021-05-09 20:43:10 +08:00
test("show external options with `--help`", async () => {
const originalStdout = await runCli("plugins/options", ["--help"]).stdout;
const pluggedStdout = await runCli("plugins/options", [
2018-01-28 00:24:25 +08:00
"--help",
"--plugin=./plugin.cjs",
2018-01-28 00:24:25 +08:00
]).stdout;
2021-05-09 20:43:10 +08:00
2025-10-09 22:00:33 +08:00
expect(
createTwoFilesPatch(
"Without plugin",
"With plugin",
originalStdout,
pluggedStdout,
),
).toMatchSnapshot();
2018-01-28 00:24:25 +08:00
});
describe("show detailed external option with `--help foo-option`", () => {
runCli("plugins/options", [
"--plugin=./plugin.cjs",
2018-01-28 00:24:25 +08:00
"--help",
"foo-option",
]).test({
status: 0,
});
});
describe("include plugin's parsers to the values of the `parser` option`", () => {
runCli("plugins/options", ["--plugin=./plugin.cjs", "--help", "parser"]).test(
{
status: 0,
},
);
});
2018-01-28 00:24:25 +08:00
describe("external options from CLI should work", () => {
runCli(
2018-01-28 00:24:25 +08:00
"plugins/options",
[
"--plugin=./plugin.cjs",
2018-01-28 00:24:25 +08:00
"--stdin-filepath",
"example.foo",
"--foo-option",
"baz",
],
{ input: "hello-world" },
).test({
stdout: "foo:baz",
stderr: "",
status: 0,
write: [],
});
});
describe("external options from config file should work", () => {
runCli(
2018-01-28 00:24:25 +08:00
"plugins/options",
["--config=./config.json", "--stdin-filepath", "example.foo"],
{ input: "hello-world" },
).test({
stdout: "foo:baz",
stderr: "",
status: 0,
write: [],
});
});