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-09-21 08:54:13 +03:00
|
|
|
const constant = require("../../src/cli-constant");
|
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
|
|
|
});
|
|
|
|
|
|
|
|
constant.detailedOptions.forEach(option => {
|
|
|
|
const optionNames = [
|
|
|
|
option.description ? option.name : null,
|
|
|
|
option.oppositeDescription ? `no-${option.name}` : null
|
|
|
|
].filter(Boolean);
|
|
|
|
|
|
|
|
optionNames.forEach(optionName => {
|
2017-10-02 19:08:34 +03:00
|
|
|
describe(`show detailed usage with --help ${optionName}`, () => {
|
|
|
|
runPrettier("cli", ["--help", optionName]).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", () => {
|
|
|
|
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
|
|
|
|
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
|
|
|
});
|