-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
41dc791
commit 3950236
Showing
2 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`--checks should print the number of files that need formatting (stderr) 1`] = ` | ||
"[warn] unformatted.js | ||
[warn] unformatted2.js | ||
[warn] Code style issues found in 2 files. Run Prettier with --write to fix." | ||
`; | ||
|
||
exports[`--checks should print the number of files that need formatting (stdout) 1`] = `"Checking formatting..."`; | ||
|
||
exports[`--checks should print the number of files that need formatting (write) 1`] = `[]`; | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (stderr) 1`] = ` | ||
"[warn] unformatted.js | ||
[warn] Code style issues found in 1 file. Run Prettier with --write to fix." | ||
`; | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (stderr) 2`] = ` | ||
"[warn] unformatted.js | ||
[warn] Code style issues found in 1 file. Run Prettier with --write to fix." | ||
`; | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (stdout) 1`] = `"Checking formatting..."`; | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (stdout) 2`] = `"Checking formatting..."`; | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (write) 1`] = `[]`; | ||
|
||
exports[`--checks works in CI just as in a non-TTY mode (write) 2`] = `[]`; | ||
|
||
exports[`checks stdin with --check (write) 1`] = `[]`; | ||
|
||
exports[`checks stdin with -c (alias for --check) (write) 1`] = `[]`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { runCli } from "../utils"; | ||
|
||
describe("checks stdin with --check", () => { | ||
runCli("with-shebang", [ | ||
"--check", | ||
"--parser", | ||
"babel", | ||
], { | ||
input: "0", | ||
}).test({ | ||
stdout: "(stdin)", | ||
stderr: "", | ||
status: "non-zero", | ||
}); | ||
}); | ||
|
||
describe("checks stdin with -c (alias for --check)", () => { | ||
runCli("with-shebang", [ | ||
"-c", | ||
"--parser", | ||
"babel", | ||
], { | ||
input: "0", | ||
}).test({ | ||
stdout: "(stdin)", | ||
stderr: "", | ||
status: "non-zero", | ||
}); | ||
}); | ||
|
||
describe("--checks works in CI just as in a non-TTY mode", () => { | ||
const result0 = runCli("write", [ | ||
"--check", | ||
"formatted.js", | ||
"unformatted.js", | ||
]).test({ | ||
status: 1, | ||
}); | ||
|
||
const result1 = runCli("write", [ | ||
"--check", | ||
"formatted.js", | ||
"unformatted.js", | ||
], { | ||
tty: false, //TODO: actually implement this, read .isTTY via a env-mockable module | ||
}).test({ | ||
status: 1, | ||
}); | ||
|
||
test("Should have same stdout", async () => { | ||
expect(await result0.stdout).toEqual(await result1.stdout); | ||
}); | ||
}); | ||
|
||
describe("--checks should print the number of files that need formatting", () => { | ||
runCli("write", [ | ||
"--check", | ||
"unformatted.js", | ||
"unformatted2.js", | ||
], { | ||
input: "0", | ||
}).test({ | ||
status: 1, | ||
}); | ||
}); |