2017-09-03 16:31:33 +03:00
|
|
|
"use strict";
|
|
|
|
|
2017-10-02 18:58:55 +03:00
|
|
|
const prettier = require("../../tests_config/require_prettier");
|
2017-09-03 16:31:33 +03:00
|
|
|
const runPrettier = require("../runPrettier");
|
2017-12-26 04:23:50 +03:00
|
|
|
const constant = require("../../src/cli/constant");
|
2018-01-27 19:24:25 +03:00
|
|
|
const util = require("../../src/cli/util");
|
2018-04-25 19:29:35 +03:00
|
|
|
const arrayify = require("../../src/utils/arrayify");
|
2017-09-03 16:31:33 +03:00
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("show version with --version", () => {
|
|
|
|
runPrettier("cli/with-shebang", ["--version"]).test({
|
|
|
|
stdout: prettier.version + "\n",
|
|
|
|
status: 0
|
|
|
|
});
|
2017-09-03 16:31:33 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("show usage with --help", () => {
|
|
|
|
runPrettier("cli", ["--help"]).test({
|
|
|
|
status: 0
|
|
|
|
});
|
2017-09-03 16:31:33 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe(`show detailed usage with --help l (alias)`, () => {
|
|
|
|
runPrettier("cli", ["--help", "l"]).test({
|
|
|
|
status: 0
|
|
|
|
});
|
2017-09-21 08:54:13 +03:00
|
|
|
});
|
|
|
|
|
2018-02-27 16:20:02 +03:00
|
|
|
describe(`show detailed usage with plugin options (automatic resolution)`, () => {
|
|
|
|
runPrettier("plugins/automatic", [
|
|
|
|
"--help",
|
|
|
|
"tab-width",
|
2018-05-09 14:17:12 +03:00
|
|
|
"--parser=bar",
|
|
|
|
`--plugin-search-dir=.`
|
2018-02-27 16:20:02 +03:00
|
|
|
]).test({
|
|
|
|
status: 0
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
describe(`show detailed usage with plugin options (manual resolution)`, () => {
|
|
|
|
runPrettier("cli", [
|
|
|
|
"--help",
|
|
|
|
"tab-width",
|
|
|
|
"--plugin=../plugins/automatic/node_modules/prettier-plugin-bar",
|
|
|
|
"--parser=bar"
|
|
|
|
]).test({
|
|
|
|
status: 0
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2018-04-25 19:29:35 +03:00
|
|
|
arrayify(
|
|
|
|
Object.assign(
|
|
|
|
{},
|
|
|
|
util.createDetailedOptionMap(
|
|
|
|
prettier.getSupportInfo(null, {
|
|
|
|
showDeprecated: true,
|
|
|
|
showUnreleased: true,
|
|
|
|
showInternal: true
|
|
|
|
}).options
|
2018-01-27 19:24:25 +03:00
|
|
|
),
|
2018-04-25 19:29:35 +03:00
|
|
|
util.normalizeDetailedOptionMap(constant.options)
|
|
|
|
),
|
|
|
|
"name"
|
|
|
|
).forEach(option => {
|
|
|
|
const optionNames = [
|
|
|
|
option.description ? option.name : null,
|
|
|
|
option.oppositeDescription ? `no-${option.name}` : null
|
|
|
|
].filter(Boolean);
|
2017-09-21 08:54:13 +03:00
|
|
|
|
2018-04-25 19:29:35 +03:00
|
|
|
optionNames.forEach(optionName => {
|
|
|
|
describe(`show detailed usage with --help ${optionName}`, () => {
|
|
|
|
runPrettier("cli", ["--help", optionName]).test({
|
|
|
|
status: 0
|
2017-10-02 19:08:34 +03:00
|
|
|
});
|
2017-09-21 08:54:13 +03:00
|
|
|
});
|
|
|
|
});
|
2018-04-25 19:29:35 +03:00
|
|
|
});
|
2017-09-21 08:54:13 +03:00
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("show warning with --help not-found", () => {
|
|
|
|
runPrettier("cli", ["--help", "not-found"]).test({
|
|
|
|
status: 0
|
|
|
|
});
|
2017-09-21 08:54:13 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("show warning with --help not-found (typo)", () => {
|
|
|
|
runPrettier("cli", ["--help", "parserr"]).test({
|
|
|
|
status: 0
|
|
|
|
});
|
2017-09-21 08:54:13 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("throw error with --write + --debug-check", () => {
|
|
|
|
runPrettier("cli", ["--write", "--debug-check"]).test({
|
|
|
|
status: 1
|
|
|
|
});
|
2017-09-03 16:31:33 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("throw error with --find-config-path + multiple files", () => {
|
|
|
|
runPrettier("cli", ["--find-config-path", "abc.js", "def.js"]).test({
|
|
|
|
status: 1
|
|
|
|
});
|
2017-09-03 16:31:33 +03:00
|
|
|
});
|
2017-09-09 06:49:22 +03:00
|
|
|
|
2018-05-09 19:53:44 +03:00
|
|
|
describe("throw error with --file-info + multiple files", () => {
|
|
|
|
runPrettier("cli", ["--file-info", "abc.js", "def.js"]).test({
|
|
|
|
status: 1
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("throw error and show usage with something unexpected", () => {
|
|
|
|
runPrettier("cli", [], { isTTY: true }).test({
|
|
|
|
status: "non-zero"
|
|
|
|
});
|
2017-09-09 06:49:22 +03:00
|
|
|
});
|