Skip to content

Commit 5f9b315

Browse files
authored
Ported test suite: ignore-unknown
- Using --write and --list-different together is forbidden in v4, the --list-different flag is unnecessary when using --write
1 parent 27e023f commit 5f9b315

9 files changed

+119
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ignored.js
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"overrides": [
3+
{
4+
"files": "*.as-js-file",
5+
"options": {
6+
"parser": "babel"
7+
}
8+
}
9+
]
10+
}

test/__fixtures__/ignore-unknown/ignored.js

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const foo= "bar";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const foo= "bar";
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PRETTIER
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PRETTIER
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`Ignored file (stderr) 1`] = `""`;
4+
5+
exports[`Ignored file (stdout) 1`] = `""`;
6+
7+
exports[`Ignored file (write) 1`] = `[]`;
8+
9+
exports[`None exist file (stderr) 1`] = `"[error] No files matching the given patterns were found"`;
10+
11+
exports[`None exist file (stdout) 1`] = `""`;
12+
13+
exports[`None exist file (write) 1`] = `[]`;
14+
15+
exports[`Not matching pattern (stderr) 1`] = `"[error] No files matching the given patterns were found"`;
16+
17+
exports[`Not matching pattern (stdout) 1`] = `""`;
18+
19+
exports[`Not matching pattern (write) 1`] = `[]`;
20+
21+
exports[`ignore-unknown alias (stdout) 1`] = `
22+
"javascript.js
23+
override.as-js-file"
24+
`;
25+
26+
exports[`ignore-unknown check (stderr) 1`] = `
27+
"[warn] javascript.js
28+
[warn] override.as-js-file
29+
[warn] Code style issues found in 2 files. Run Prettier with --write to fix."
30+
`;
31+
32+
exports[`ignore-unknown check (stdout) 1`] = `"Checking formatting..."`;
33+
34+
exports[`ignore-unknown check (write) 1`] = `[]`;
35+
36+
exports[`ignore-unknown dir (stdout) 1`] = `
37+
"javascript.js
38+
override.as-js-file"
39+
`;
40+
41+
exports[`ignore-unknown pattern (stdout) 1`] = `
42+
"javascript.js
43+
override.as-js-file"
44+
`;

test/__tests__/ignore-unknown.js

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import { runCli } from "../utils";
2+
3+
describe("ignore-unknown dir", () => {
4+
runCli("ignore-unknown", [
5+
".",
6+
"--ignore-unknown",
7+
"--list-different",
8+
]).test({
9+
status: "non-zero",
10+
stderr: "",
11+
write: [],
12+
});
13+
});
14+
15+
describe("ignore-unknown alias", () => {
16+
runCli("ignore-unknown", [".", "-u", "--list-different"]).test({
17+
status: "non-zero",
18+
stderr: "",
19+
write: [],
20+
});
21+
});
22+
23+
describe("ignore-unknown pattern", () => {
24+
runCli("ignore-unknown", [
25+
"*",
26+
"--ignore-unknown",
27+
"--list-different",
28+
]).test({
29+
status: "non-zero",
30+
stderr: "",
31+
write: [],
32+
});
33+
});
34+
35+
describe("ignore-unknown check", () => {
36+
runCli("ignore-unknown", [".", "--ignore-unknown", "--check"]).test({
37+
status: 1,
38+
});
39+
});
40+
41+
describe("None exist file", () => {
42+
runCli("ignore-unknown", ["non-exist-file", "--ignore-unknown"]).test({
43+
status: 1,
44+
});
45+
});
46+
47+
describe("Not matching pattern", () => {
48+
runCli("ignore-unknown", [
49+
"*.non-exist-pattern",
50+
"--ignore-unknown",
51+
]).test({
52+
status: 1,
53+
});
54+
});
55+
56+
describe("Ignored file", () => {
57+
runCli("ignore-unknown", ["ignored.js", "--ignore-unknown"]).test({
58+
status: 0,
59+
});
60+
});

0 commit comments

Comments
 (0)