Skip to content

Commit 2cdb5d5

Browse files
43081jfabiospampinato
authored andcommitted
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 2cdb5d5

9 files changed

Lines changed: 164 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ignored.js
Lines changed: 10 additions & 0 deletions
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.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const foo= "bar";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
const foo= "bar";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PRETTIER
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
PRETTIER
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
`;
45+
46+
exports[`ignore-unknown write (stdout) 1`] = `
47+
"javascript.js
48+
override.as-js-file"
49+
`;
50+
51+
exports[`ignore-unknown write (write) 1`] = `
52+
[
53+
{
54+
"content": "const foo = "bar";
55+
",
56+
"filename": "javascript.js",
57+
},
58+
{
59+
"content": "const foo = "bar";
60+
",
61+
"filename": "override.as-js-file",
62+
},
63+
]
64+
`;

test/__tests__/ignore-unknown.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
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", [
17+
".",
18+
"-u",
19+
"--list-different",
20+
]).test({
21+
status: "non-zero",
22+
stderr: "",
23+
write: [],
24+
});
25+
});
26+
27+
describe("ignore-unknown pattern", () => {
28+
runCli("ignore-unknown", [
29+
"*",
30+
"--ignore-unknown",
31+
"--list-different",
32+
]).test({
33+
status: "non-zero",
34+
stderr: "",
35+
write: [],
36+
});
37+
});
38+
39+
describe("ignore-unknown write", () => {
40+
runCli("ignore-unknown", [
41+
".",
42+
"--ignore-unknown",
43+
"--write",
44+
]).test({
45+
status: 0,
46+
stderr: "",
47+
});
48+
});
49+
50+
describe("ignore-unknown check", () => {
51+
runCli("ignore-unknown", [
52+
".",
53+
"--ignore-unknown",
54+
"--check",
55+
]).test({
56+
status: 1,
57+
});
58+
});
59+
60+
describe("None exist file", () => {
61+
runCli("ignore-unknown", [
62+
"non-exist-file",
63+
"--ignore-unknown",
64+
]).test({
65+
status: 1,
66+
});
67+
});
68+
69+
describe("Not matching pattern", () => {
70+
runCli("ignore-unknown", [
71+
"*.non-exist-pattern",
72+
"--ignore-unknown",
73+
]).test({
74+
status: 1,
75+
});
76+
});
77+
78+
describe("Ignored file", () => {
79+
runCli("ignore-unknown", [
80+
"ignored.js",
81+
"--ignore-unknown",
82+
]).test({
83+
status: 0,
84+
});
85+
});

0 commit comments

Comments
 (0)