2018-12-19 14:03:30 +00:00
|
|
|
describe("checks stdin with --check", () => {
|
2023-04-11 08:44:23 +08:00
|
|
|
runCli("cli/with-shebang", ["--check", "--parser", "babel"], {
|
2018-12-19 14:03:30 +00:00
|
|
|
input: "0",
|
|
|
|
|
}).test({
|
2023-03-30 14:25:28 +08:00
|
|
|
stdout: "(stdin)",
|
2018-12-19 14:03:30 +00:00
|
|
|
stderr: "",
|
|
|
|
|
status: "non-zero",
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe("checks stdin with -c (alias for --check)", () => {
|
2023-04-11 08:44:23 +08:00
|
|
|
runCli("cli/with-shebang", ["-c", "--parser", "babel"], {
|
2018-12-19 14:03:30 +00:00
|
|
|
input: "0",
|
|
|
|
|
}).test({
|
2023-03-30 14:25:28 +08:00
|
|
|
stdout: "(stdin)",
|
2018-12-19 14:03:30 +00:00
|
|
|
stderr: "",
|
|
|
|
|
status: "non-zero",
|
|
|
|
|
});
|
|
|
|
|
});
|
2019-01-30 06:08:03 +00:00
|
|
|
|
|
|
|
|
describe("--checks works in CI just as in a non-TTY mode", () => {
|
2023-04-11 08:44:23 +08:00
|
|
|
const result0 = runCli(
|
2019-01-30 06:08:03 +00:00
|
|
|
"cli/write",
|
|
|
|
|
["--check", "formatted.js", "unformatted.js"],
|
|
|
|
|
{
|
|
|
|
|
stdoutIsTTY: true,
|
2020-04-08 02:37:57 +03:00
|
|
|
ci: true,
|
2019-01-30 06:08:03 +00:00
|
|
|
},
|
|
|
|
|
).test({
|
|
|
|
|
status: 1,
|
|
|
|
|
});
|
|
|
|
|
|
2023-04-11 08:44:23 +08:00
|
|
|
const result1 = runCli(
|
2019-01-30 06:08:03 +00:00
|
|
|
"cli/write",
|
|
|
|
|
["--check", "formatted.js", "unformatted.js"],
|
|
|
|
|
{
|
|
|
|
|
stdoutIsTTY: false,
|
|
|
|
|
},
|
|
|
|
|
).test({
|
|
|
|
|
status: 1,
|
|
|
|
|
});
|
|
|
|
|
|
2021-05-09 20:43:10 +08:00
|
|
|
test("Should have same stdout", async () => {
|
2026-01-22 23:53:24 +08:00
|
|
|
expect(await result0.stdout).toBe(await result1.stdout);
|
2021-05-09 20:43:10 +08:00
|
|
|
});
|
2019-01-30 06:08:03 +00:00
|
|
|
});
|
2022-04-07 02:47:13 +01:00
|
|
|
|
|
|
|
|
describe("--checks should print the number of files that need formatting", () => {
|
2023-04-11 08:44:23 +08:00
|
|
|
runCli("cli/write", ["--check", "unformatted.js", "unformatted2.js"], {
|
2022-04-07 02:47:13 +01:00
|
|
|
input: "0",
|
|
|
|
|
}).test({
|
|
|
|
|
status: 1,
|
|
|
|
|
});
|
|
|
|
|
});
|