Files
test-repo/tests/integration/__tests__/plugin-options.js
T
164a6e2351 Switch CLI to async (#10804)
* Switch CLI to async

* Rewrite test

* Fix tests

* Comment out failed test

* Comment out failed test

* Fix test

Co-authored-by: Connor Peet <connor@peet.io>

* Update patterns-dirs.js

* Fix `hasRunningCli` flag

* Fix grammar

* Update tests/integration/runPrettier.js

Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>

Co-authored-by: Connor Peet <connor@peet.io>
Co-authored-by: Georgii Dolzhykov <thorn.mailbox@gmail.com>
2021-05-09 15:43:10 +03:00

68 lines
1.5 KiB
JavaScript

"use strict";
const snapshotDiff = require("snapshot-diff");
const runPrettier = require("../runPrettier");
test("show external options with `--help`", async () => {
const originalStdout = await runPrettier("plugins/options", ["--help"])
.stdout;
const pluggedStdout = await runPrettier("plugins/options", [
"--help",
"--plugin=./plugin",
]).stdout;
expect(snapshotDiff(originalStdout, pluggedStdout)).toMatchSnapshot();
});
describe("show detailed external option with `--help foo-option`", () => {
runPrettier("plugins/options", [
"--plugin=./plugin",
"--help",
"foo-option",
]).test({
status: 0,
});
});
describe("include plugin's parsers to the values of the `parser` option`", () => {
runPrettier("plugins/options", [
"--plugin=./plugin",
"--help",
"parser",
]).test({
status: 0,
});
});
describe("external options from CLI should work", () => {
runPrettier(
"plugins/options",
[
"--plugin=./plugin",
"--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", () => {
runPrettier(
"plugins/options",
["--config=./config.json", "--stdin-filepath", "example.foo"],
{ input: "hello-world" }
).test({
stdout: "foo:baz",
stderr: "",
status: 0,
write: [],
});
});