Files
test-repo/tests_integration/__tests__/early-exit.js
T

107 lines
2.4 KiB
JavaScript
Raw Normal View History

2017-09-03 21:31:33 +08:00
"use strict";
2018-05-27 21:36:12 +10:00
const prettier = require("prettier/local");
2017-09-03 21:31:33 +08:00
const runPrettier = require("../runPrettier");
describe("show version with --version", () => {
runPrettier("cli/with-shebang", ["--version"]).test({
stdout: prettier.version + "\n",
2020-03-21 22:07:52 +02:00
status: 0,
});
2017-09-03 21:31:33 +08:00
});
describe("show usage with --help", () => {
runPrettier("cli", ["--help"]).test({
2020-03-21 22:07:52 +02:00
status: 0,
});
2017-09-03 21:31:33 +08:00
});
2020-01-14 18:58:20 +08:00
describe("show detailed usage with --help l (alias)", () => {
runPrettier("cli", ["--help", "l"]).test({
2020-03-21 22:07:52 +02:00
status: 0,
});
2017-09-21 13:54:13 +08:00
});
2020-01-14 18:58:20 +08:00
describe("show detailed usage with plugin options (automatic resolution)", () => {
runPrettier("plugins/automatic", [
"--help",
"tab-width",
"--parser=bar",
2020-03-21 22:07:52 +02:00
"--plugin-search-dir=.",
]).test({
2020-03-21 22:07:52 +02:00
status: 0,
});
});
2020-01-14 18:58:20 +08:00
describe("show detailed usage with plugin options (manual resolution)", () => {
runPrettier("cli", [
"--help",
"tab-width",
"--plugin=../plugins/automatic/node_modules/prettier-plugin-bar",
2020-03-21 22:07:52 +02:00
"--parser=bar",
]).test({
2020-03-21 22:07:52 +02:00
status: 0,
});
});
describe("throw error with --help not-found", () => {
runPrettier("cli", ["--help", "not-found"]).test({
2020-03-21 22:07:52 +02:00
status: 1,
});
2017-09-21 13:54:13 +08:00
});
describe("show warning with --help not-found (typo)", () => {
runPrettier("cli", [
"--help",
// cspell:disable-next-line
"parserr",
]).test({
2020-03-21 22:07:52 +02:00
status: 0,
});
2017-09-21 13:54:13 +08:00
});
2018-12-19 14:03:30 +00:00
describe("throw error with --check + --list-different", () => {
runPrettier("cli", ["--check", "--list-different"]).test({
2020-03-21 22:07:52 +02:00
status: 1,
2018-12-19 14:03:30 +00:00
});
});
describe("throw error with --write + --debug-check", () => {
runPrettier("cli", ["--write", "--debug-check"]).test({
2020-03-21 22:07:52 +02:00
status: 1,
});
2017-09-03 21:31:33 +08:00
});
describe("throw error with --find-config-path + multiple files", () => {
runPrettier("cli", ["--find-config-path", "abc.js", "def.js"]).test({
2020-03-21 22:07:52 +02:00
status: 1,
});
2017-09-03 21:31:33 +08:00
});
2017-09-09 11:49:22 +08:00
describe("throw error with --file-info + multiple files", () => {
runPrettier("cli", ["--file-info", "abc.js", "def.js"]).test({
2020-03-21 22:07:52 +02:00
status: 1,
});
});
describe("throw error and show usage with something unexpected", () => {
runPrettier("cli", [], { isTTY: true }).test({
2020-03-21 22:07:52 +02:00
status: "non-zero",
});
2017-09-09 11:49:22 +08:00
});
2020-03-23 03:32:05 +02:00
describe("node version error", () => {
const originalProcessVersion = process.version;
try {
Object.defineProperty(process, "version", {
value: "v8.0.0",
writable: false,
});
runPrettier("cli", ["--help"]).test({ status: 1 });
} finally {
Object.defineProperty(process, "version", {
value: originalProcessVersion,
writable: false,
});
}
});