Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 65 additions & 48 deletions test/__tests__/__snapshots__/arg-parsing.js.snap
Original file line number Diff line number Diff line change
@@ -1,69 +1,86 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`allow overriding flags (stderr) 1`] = `""`;

exports[`allow overriding flags (write) 1`] = `[]`;

exports[`boolean flags do not swallow the next argument (stderr) 1`] = `""`;

exports[`boolean flags do not swallow the next argument (stdout) 1`] = `"console.log('could be single quote and without semi');"`;

exports[`boolean flags do not swallow the next argument (write) 1`] = `[]`;

exports[`negated options work (stderr) 1`] = `""`;
exports[`allow overriding flags 1`] = `
{
"stderr": "",
"write": [],
}
`;

exports[`negated options work (stdout) 1`] = `"console.log("could be single quote and without semi")"`;
exports[`boolean flags do not swallow the next argument 1`] = `
{
"stderr": "",
"stdout": "console.log('could be single quote and without semi');",
"write": [],
}
`;

exports[`negated options work (write) 1`] = `[]`;
exports[`negated options work 1`] = `
{
"stderr": "",
"stdout": "console.log("could be single quote and without semi")",
"write": [],
}
`;

exports[`number file/dir (stdout) 1`] = `"1/file-in-dir-named-1.js"`;
exports[`number file/dir 1`] = `
{
"stdout": "1/file-in-dir-named-1.js",
}
`;

exports[`number file/dir (stdout) 2`] = `"2.2/file-in-dir-named-2.2.js"`;
exports[`number file/dir 2`] = `
{
"stdout": "2.2/file-in-dir-named-2.2.js",
}
`;

exports[`number file/dir (stdout) 3`] = `"3"`;
exports[`number file/dir 3`] = `
{
"stdout": "3",
}
`;

exports[`number file/dir (stdout) 4`] = `"4.44"`;
exports[`number file/dir 4`] = `
{
"stdout": "4.44",
}
`;

exports[`number file/dir (stdout) 5`] = `
"1/file-in-dir-named-1.js
exports[`number file/dir 5`] = `
{
"stdout": "1/file-in-dir-named-1.js
2.2/file-in-dir-named-2.2.js
3
4.44"
`;

exports[`options with \`cliName\` should not allow to pass directly (stderr) 1`] = `
"[warn] Ignored unknown option --filepath=file.js.
[error] No parser and no file path given, couldn't infer a parser."
4.44",
}
`;

exports[`options with \`cliName\` should not allow to pass directly (stdout) 1`] = `"prettier();"`;

exports[`options with \`cliName\` should not allow to pass directly (stdout) 2`] = `""`;

exports[`unknown negated options are errored (stderr) 1`] = `
"
exports[`unknown negated options are errored 1`] = `
{
"stderr": "
Unknown option: "unknown"
"
",
"stdout": "",
"write": [],
}
`;

exports[`unknown negated options are errored (stdout) 1`] = `""`;

exports[`unknown negated options are errored (write) 1`] = `[]`;

exports[`unknown options are errored (stderr) 1`] = `
"
exports[`unknown options are errored 1`] = `
{
"stderr": "
Unknown option: "unknown"
"
",
"stdout": "",
"write": [],
}
`;

exports[`unknown options are errored (stdout) 1`] = `""`;

exports[`unknown options are errored (write) 1`] = `[]`;

exports[`unknown options may trigger a suggestion \`_\` (stderr) 1`] = `
"
exports[`unknown options may trigger a suggestion \`_\` 1`] = `
{
"stderr": "
Unknown option: "a". Did you mean "v"?
"
",
"stdout": "",
}
`;

exports[`unknown options may trigger a suggestion \`_\` (stdout) 1`] = `""`;
54 changes: 31 additions & 23 deletions test/__tests__/__snapshots__/check.js.snap
Original file line number Diff line number Diff line change
@@ -1,33 +1,41 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`--checks should print the number of files that need formatting (stderr) 1`] = `
"[warn] unformatted.js
exports[`--checks should print the number of files that need formatting 1`] = `
{
"stderr": "[warn] unformatted.js
[warn] unformatted2.js
[warn] Code style issues found in 2 files. Run Prettier with --write to fix."
[warn] Code style issues found in 2 files. Run Prettier with --write to fix.",
"stdout": "Checking formatting...",
"write": [],
}
`;

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 1`] = `
{
"stderr": "[warn] unformatted.js
[warn] Code style issues found in 1 file. Run Prettier with --write to fix.",
"stdout": "Checking formatting...",
"write": [],
}
`;

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 2`] = `
{
"stderr": "[warn] unformatted.js
[warn] Code style issues found in 1 file. Run Prettier with --write to fix.",
"stdout": "Checking formatting...",
"write": [],
}
`;

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 --check 1`] = `
{
"write": [],
}
`;

exports[`checks stdin with -c (alias for --check) (write) 1`] = `[]`;
exports[`checks stdin with -c (alias for --check) 1`] = `
{
"write": [],
}
`;
23 changes: 13 additions & 10 deletions test/__tests__/__snapshots__/cursor-offset.js.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`cursorOffset should not be affected by full-width character (stdout) 1`] = `
"const x = [
exports[`cursorOffset should not be affected by full-width character 1`] = `
{
"stdout": "const x = [
"中文",
"中文",
"中文",
Expand All @@ -13,13 +14,15 @@ exports[`cursorOffset should not be affected by full-width character (stdout) 1`
"中文",
"中文",
"中文",
];"
];",
"write": [],
}
`;

exports[`cursorOffset should not be affected by full-width character (write) 1`] = `[]`;

exports[`write cursorOffset to stderr with --cursor-offset <int> (stderr) 1`] = `"1"`;

exports[`write cursorOffset to stderr with --cursor-offset <int> (stdout) 1`] = `"1;"`;

exports[`write cursorOffset to stderr with --cursor-offset <int> (write) 1`] = `[]`;
exports[`write cursorOffset to stderr with --cursor-offset <int> 1`] = `
{
"stderr": "1",
"stdout": "1;",
"write": [],
}
`;
121 changes: 62 additions & 59 deletions test/__tests__/__snapshots__/early-exit.js.snap
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`show usage with --help (stderr) 1`] = `""`;

exports[`show usage with --help (stdout) 1`] = `
"
exports[`show usage with --help 1`] = `
{
"stderr": "",
"stdout": "
prettier 3.3.3

USAGE
Expand Down Expand Up @@ -131,81 +131,84 @@ exports[`show usage with --help (stdout) 1`] = `
--require-pragma Require either "@prettier" or "@format" to be present in the file's first docblock comment in order for it to be formatted
Defaults to "false"
--stdin-filepath <path> Path to the file to pretend that stdin comes from
"
",
"write": [],
}
`;

exports[`show usage with --help (write) 1`] = `[]`;

exports[`show version with --version (stderr) 1`] = `""`;

exports[`show version with --version (write) 1`] = `[]`;
exports[`show version with --version 1`] = `
{
"stderr": "",
"write": [],
}
`;

exports[`throw error with --check + --list-different (stderr) 1`] = `
"
exports[`throw error with --check + --list-different 1`] = `
{
"stderr": "
Incompatible options: "check" and "list-different" cannot be used together
"
",
"stdout": "",
"write": [],
}
`;

exports[`throw error with --check + --list-different (stdout) 1`] = `""`;

exports[`throw error with --check + --list-different (write) 1`] = `[]`;

exports[`throw error with --check + --write (stderr) 1`] = `
"
exports[`throw error with --check + --write 1`] = `
{
"stderr": "
Incompatible options: "check" and "write" cannot be used together
"
",
"stdout": "",
"write": [],
}
`;

exports[`throw error with --check + --write (stdout) 1`] = `""`;

exports[`throw error with --check + --write (write) 1`] = `[]`;

exports[`throw error with --list-different + --write (stderr) 1`] = `
"
exports[`throw error with --list-different + --write 1`] = `
{
"stderr": "
Incompatible options: "list-different" and "write" cannot be used together
"
",
"stdout": "",
"write": [],
}
`;

exports[`throw error with --list-different + --write (stdout) 1`] = `""`;

exports[`throw error with --list-different + --write (write) 1`] = `[]`;

exports[`throw error with something unexpected (stderr) 1`] = `
"
exports[`throw error with something unexpected 1`] = `
{
"stderr": "
Expected at least one target file/dir/glob
"
",
"stdout": "",
"write": [],
}
`;

exports[`throw error with something unexpected (stdout) 1`] = `""`;

exports[`throw error with something unexpected (write) 1`] = `[]`;

exports[`throw unsupported error with --file-info (stderr) 1`] = `
"
exports[`throw unsupported error with --file-info 1`] = `
{
"stderr": "
The "--file-info" option is not currently supported, please open an issue on GitHub if you need it
"
",
"stdout": "",
"write": [],
}
`;

exports[`throw unsupported error with --file-info (stdout) 1`] = `""`;

exports[`throw unsupported error with --file-info (write) 1`] = `[]`;

exports[`throw unsupported error with --find-config-path (stderr) 1`] = `
"
exports[`throw unsupported error with --find-config-path 1`] = `
{
"stderr": "
Unknown option: "find-config-path"
"
",
"stdout": "",
"write": [],
}
`;

exports[`throw unsupported error with --find-config-path (stdout) 1`] = `""`;

exports[`throw unsupported error with --find-config-path (write) 1`] = `[]`;

exports[`throw unsupported error with --support-info (stderr) 1`] = `
"
exports[`throw unsupported error with --support-info 1`] = `
{
"stderr": "
The "--support-info" option is not currently supported, please open an issue on GitHub if you need it
"
",
"stdout": "",
"write": [],
}
`;

exports[`throw unsupported error with --support-info (stdout) 1`] = `""`;

exports[`throw unsupported error with --support-info (write) 1`] = `[]`;
Loading