Files
test-repo/tests_integration/__tests__/plugin-options-string.js
T

56 lines
1.3 KiB
JavaScript
Raw Normal View History

"use strict";
const snapshotDiff = require("snapshot-diff");
2020-06-26 20:30:21 +08:00
const runPrettier = require("../runPrettier");
describe("show external options with `--help`", () => {
const originalStdout = runPrettier("plugins/options-string", ["--help"])
.stdout;
const pluggedStdout = runPrettier("plugins/options-string", [
"--help",
2020-03-21 22:07:52 +02:00
"--plugin=./plugin",
]).stdout;
expect(snapshotDiff(originalStdout, pluggedStdout)).toMatchSnapshot();
});
describe("show detailed external option with `--help foo-string`", () => {
runPrettier("plugins/options-string", [
"--plugin=./plugin",
"--help",
2020-03-21 22:07:52 +02:00
"foo-string",
]).test({
2020-03-21 22:07:52 +02:00
status: 0,
});
});
describe("external options from CLI should work", () => {
runPrettier(
"plugins/options-string",
[
"--plugin=./plugin",
"--stdin-filepath",
"example.foo",
"--foo-string",
2020-03-21 22:07:52 +02:00
"baz",
],
{ input: "hello-world" }
).test({
stdout: "foo:baz",
stderr: "",
status: 0,
2020-03-21 22:07:52 +02:00
write: [],
});
});
describe("external options from config file should work", () => {
runPrettier(
"plugins/options-string",
["--config=./config.json", "--stdin-filepath", "example.foo"],
{ input: "hello-world" }
).test({
stdout: "foo:baz",
stderr: "",
status: 0,
2020-03-21 22:07:52 +02:00
write: [],
});
});