2017-09-03 16:31:33 +03:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const runPrettier = require("../runPrettier");
|
|
|
|
|
2017-09-28 12:30:51 +03:00
|
|
|
expect.addSnapshotSerializer(require("../path-serializer"));
|
2017-09-03 16:31:33 +03:00
|
|
|
|
2018-08-11 11:35:18 +03:00
|
|
|
describe("throw error for unsupported extension", () => {
|
|
|
|
runPrettier("cli/config/invalid", [
|
|
|
|
"--config",
|
|
|
|
"file/.prettierrc.unsupported"
|
|
|
|
]).test({
|
|
|
|
status: "non-zero"
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("throw error with invalid config format", () => {
|
|
|
|
runPrettier("cli/config/invalid", ["--config", "file/.prettierrc"]).test({
|
|
|
|
status: "non-zero"
|
|
|
|
});
|
2017-09-03 16:31:33 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("throw error with invalid config target (directory)", () => {
|
|
|
|
runPrettier("cli/config/invalid", [
|
2017-09-03 16:31:33 +03:00
|
|
|
"--config",
|
|
|
|
"folder/.prettierrc" // this is a directory
|
2017-10-02 19:08:34 +03:00
|
|
|
]).test({
|
|
|
|
status: "non-zero"
|
|
|
|
});
|
2017-09-03 16:31:33 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("throw error with invalid config option (int)", () => {
|
|
|
|
runPrettier("cli/config/invalid", ["--config", "option/int"]).test({
|
|
|
|
status: "non-zero"
|
|
|
|
});
|
2017-09-03 16:31:33 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("throw error with invalid config option (trailingComma)", () => {
|
|
|
|
runPrettier("cli/config/invalid", ["--config", "option/trailingComma"]).test({
|
|
|
|
status: "non-zero"
|
|
|
|
});
|
2017-09-03 16:31:33 +03:00
|
|
|
});
|
2017-09-05 01:56:23 +03:00
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("throw error with invalid config precedence option (configPrecedence)", () => {
|
|
|
|
runPrettier("cli/config/invalid", [
|
2017-09-05 01:56:23 +03:00
|
|
|
"--config-precedence",
|
|
|
|
"option/configPrecedence"
|
2017-10-02 19:08:34 +03:00
|
|
|
]).test({
|
|
|
|
status: "non-zero"
|
|
|
|
});
|
2017-09-05 01:56:23 +03:00
|
|
|
});
|
2017-09-28 20:59:32 +03:00
|
|
|
|
2018-05-23 22:55:06 +03:00
|
|
|
// Tests below require --parser to prevent an error (no parser/filepath specified)
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("show warning with unknown option", () => {
|
2018-05-23 22:55:06 +03:00
|
|
|
runPrettier("cli/config/invalid", [
|
|
|
|
"--config",
|
|
|
|
"option/unknown",
|
|
|
|
"--parser",
|
2018-12-27 16:05:19 +03:00
|
|
|
"babel"
|
2018-05-23 22:55:06 +03:00
|
|
|
]).test({
|
2017-10-02 19:08:34 +03:00
|
|
|
status: 0
|
|
|
|
});
|
2017-09-28 20:59:32 +03:00
|
|
|
});
|
2018-01-18 10:26:27 +03:00
|
|
|
|
|
|
|
describe("show warning with kebab-case option key", () => {
|
2018-05-23 22:55:06 +03:00
|
|
|
runPrettier("cli/config/invalid", [
|
|
|
|
"--config",
|
|
|
|
"option/kebab-case",
|
|
|
|
"--parser",
|
2018-12-27 16:05:19 +03:00
|
|
|
"babel"
|
2018-05-23 22:55:06 +03:00
|
|
|
]).test({
|
2018-01-18 10:26:27 +03:00
|
|
|
status: 0
|
|
|
|
});
|
|
|
|
});
|