# Conflicts: # src/language-css/parser-postcss.js # tests/integration/__tests__/arg-parsing.js # tests/integration/__tests__/check.js # tests/integration/__tests__/config-invalid.js # tests/integration/__tests__/config-resolution.js # tests/integration/__tests__/cursor-offset.js # tests/integration/__tests__/debug-check.js # tests/integration/__tests__/debug-print-ast.js # tests/integration/__tests__/debug-print-comments.js # tests/integration/__tests__/debug-print-doc.js # tests/integration/__tests__/early-exit.js # tests/integration/__tests__/error-on-unmatched-pattern.js # tests/integration/__tests__/file-info.js # tests/integration/__tests__/help-options.js # tests/integration/__tests__/ignore-absolute-path.js # tests/integration/__tests__/ignore-emoji.js # tests/integration/__tests__/ignore-in-subdirectories.js # tests/integration/__tests__/ignore-path.js # tests/integration/__tests__/ignore-relative-path.js # tests/integration/__tests__/ignore-unknown.js # tests/integration/__tests__/ignore-vcs-files.js # tests/integration/__tests__/infer-parser.js # tests/integration/__tests__/invalid-ignore.js # tests/integration/__tests__/line-suffix-boundary.js # tests/integration/__tests__/list-different.js # tests/integration/__tests__/loglevel.js # tests/integration/__tests__/parser-api.js # tests/integration/__tests__/patterns-dirs.js # tests/integration/__tests__/patterns-glob.js # tests/integration/__tests__/patterns.js # tests/integration/__tests__/piped-output.js # tests/integration/__tests__/plugin-default-options.js # tests/integration/__tests__/plugin-extensions.js # tests/integration/__tests__/plugin-flush-line-suffix.js # tests/integration/__tests__/plugin-options-string.js # tests/integration/__tests__/plugin-options.js # tests/integration/__tests__/plugin-precedence.js # tests/integration/__tests__/plugin-preprocess.js # tests/integration/__tests__/plugin-resolution.js # tests/integration/__tests__/plugin-virtual-directory.js # tests/integration/__tests__/skip-folders.js # tests/integration/__tests__/stdin-filepath.js # tests/integration/__tests__/support-info.js # tests/integration/__tests__/syntax-error.js # tests/integration/__tests__/with-config-precedence.js # tests/integration/__tests__/with-node-modules.js # tests/integration/__tests__/with-parser-inference.js # tests/integration/__tests__/with-shebang.js # tests/integration/__tests__/write.js
108 lines
2.7 KiB
JavaScript
108 lines
2.7 KiB
JavaScript
import runPrettier from "../run-prettier.js";
|
|
|
|
describe("output with --check + unformatted differs when piped", () => {
|
|
const cli0 = runPrettier(
|
|
"cli/write",
|
|
["--write", "--check", "--no-color", "unformatted.js"],
|
|
{ stdoutIsTTY: true }
|
|
).test({
|
|
status: 0,
|
|
});
|
|
|
|
const cli1 = runPrettier(
|
|
"cli/write",
|
|
["--write", "--check", "--no-color", "unformatted.js"],
|
|
{ stdoutIsTTY: false }
|
|
).test({
|
|
status: 0,
|
|
});
|
|
|
|
test("Result", async () => {
|
|
const result0 = await cli0;
|
|
const result1 = await cli1;
|
|
|
|
expect(result0.stdout.length).toBeGreaterThan(result1.stdout.length);
|
|
expect(result0.write).toEqual(result1.write);
|
|
});
|
|
});
|
|
|
|
describe("no file diffs with --check + formatted file", () => {
|
|
const cli0 = runPrettier(
|
|
"cli/write",
|
|
["--write", "--check", "--no-color", "formatted.js"],
|
|
{ stdoutIsTTY: true }
|
|
).test({
|
|
status: 0,
|
|
});
|
|
|
|
const cli1 = runPrettier(
|
|
"cli/write",
|
|
["--write", "--check", "--no-color", "formatted.js"],
|
|
{ stdoutIsTTY: false }
|
|
).test({
|
|
status: 0,
|
|
});
|
|
|
|
test("Result", async () => {
|
|
const result0 = await cli0;
|
|
const result1 = await cli1;
|
|
|
|
expect(result0.stdout).not.toEqual(result1.stdout);
|
|
expect(result0.stdout.length).toBeGreaterThan(result1.stdout.length);
|
|
expect(result0.write).toEqual(result1.write);
|
|
});
|
|
});
|
|
|
|
describe("output with --list-different + unformatted differs when piped", () => {
|
|
const cli0 = runPrettier(
|
|
"cli/write",
|
|
["--write", "--list-different", "--no-color", "unformatted.js"],
|
|
{ stdoutIsTTY: true }
|
|
).test({
|
|
status: 0,
|
|
});
|
|
|
|
const cli1 = runPrettier(
|
|
"cli/write",
|
|
["--write", "--list-different", "--no-color", "unformatted.js"],
|
|
{ stdoutIsTTY: false }
|
|
).test({
|
|
status: 0,
|
|
});
|
|
|
|
test("Result", async () => {
|
|
const result0 = await cli0;
|
|
const result1 = await cli1;
|
|
|
|
expect(result0.stdout.length).toBeGreaterThan(result1.stdout.length);
|
|
expect(result0.write).toEqual(result1.write);
|
|
});
|
|
});
|
|
|
|
describe("no file diffs with --list-different + formatted file", () => {
|
|
const cli0 = runPrettier(
|
|
"cli/write",
|
|
["--write", "--list-different", "--no-color", "formatted.js"],
|
|
{ stdoutIsTTY: true }
|
|
).test({
|
|
status: 0,
|
|
});
|
|
|
|
const cli1 = runPrettier(
|
|
"cli/write",
|
|
["--write", "--list-different", "--no-color", "formatted.js"],
|
|
{ stdoutIsTTY: false }
|
|
).test({
|
|
status: 0,
|
|
});
|
|
|
|
test("Result", async () => {
|
|
const result0 = await cli0;
|
|
const result1 = await cli1;
|
|
|
|
expect(result0.stdout).not.toEqual(result1.stdout);
|
|
expect(result0.stdout.length).toBeGreaterThan(result1.stdout.length);
|
|
expect(result0.write).toEqual(result1.write);
|
|
});
|
|
});
|