# Conflicts: # tests/config/install-prettier.js # tests/format/js/cursor/jsfmt.spec.js # tests/integration/__tests__/doc-trim.js # tests/integration/__tests__/format.js # tests/integration/__tests__/line-suffix-boundary.js # tests/integration/__tests__/load-toml.js # tests/integration/__tests__/stdin-filepath.js # tests/integration/__tests__/with-parser-inference.js
76 lines
1.7 KiB
JavaScript
76 lines
1.7 KiB
JavaScript
import runPrettier from "../run-prettier.js";
|
|
import jestPathSerializer from "../path-serializer.js";
|
|
|
|
expect.addSnapshotSerializer(jestPathSerializer);
|
|
|
|
describe("ignores files when executing in a subdirectory", () => {
|
|
runPrettier("cli/ignore-in-subdirectories/web1", [
|
|
"ignore-me/should-ignore.js",
|
|
"--ignore-path",
|
|
"../.prettierignore",
|
|
"-l",
|
|
]).test({
|
|
status: 0,
|
|
});
|
|
|
|
runPrettier("cli/ignore-in-subdirectories/web1", [
|
|
"ignore-me/subdirectory/should-ignore.js",
|
|
"--ignore-path",
|
|
"../.prettierignore",
|
|
"-l",
|
|
]).test({
|
|
status: 0,
|
|
});
|
|
});
|
|
|
|
describe("formats files when executing in a subdirectory", () => {
|
|
runPrettier("cli/ignore-in-subdirectories/web1", [
|
|
"should-not-ignore.js",
|
|
"--ignore-path",
|
|
"../.prettierignore",
|
|
"-l",
|
|
]).test({
|
|
status: 1,
|
|
});
|
|
|
|
runPrettier("cli/ignore-in-subdirectories/web2", [
|
|
"should-not-ignore.js",
|
|
"--ignore-path",
|
|
"../.prettierignore",
|
|
"-l",
|
|
]).test({
|
|
status: 1,
|
|
});
|
|
});
|
|
|
|
describe("ignore files when executing in a subdirectory and using stdin", () => {
|
|
runPrettier(
|
|
"cli/ignore-in-subdirectories/web1",
|
|
[
|
|
"--ignore-path",
|
|
"../.prettierignore",
|
|
"--stdin-filepath",
|
|
"ignore-me/example.js",
|
|
],
|
|
{
|
|
input: "hello_world( );",
|
|
}
|
|
).test({
|
|
stdout: "hello_world( );",
|
|
status: 0,
|
|
});
|
|
});
|
|
|
|
describe("formats files when executing in a subdirectory and using stdin", () => {
|
|
runPrettier(
|
|
"cli/ignore-in-subdirectories/web1",
|
|
["--ignore-path", "../.prettierignore", "--stdin-filepath", "example.js"],
|
|
{
|
|
input: "hello_world( );",
|
|
}
|
|
).test({
|
|
stdout: "hello_world();\n",
|
|
status: 0,
|
|
});
|
|
});
|