2017-07-04 18:55:06 +03:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
const runPrettier = require("../runPrettier");
|
|
|
|
|
2017-11-07 06:39:07 +03:00
|
|
|
expect.addSnapshotSerializer(require("../path-serializer"));
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("multiple patterns", () => {
|
|
|
|
runPrettier("cli/multiple-patterns", [
|
2017-07-04 18:55:06 +03:00
|
|
|
"directory/**/*.js",
|
|
|
|
"other-directory/**/*.js",
|
|
|
|
"-l"
|
2017-10-02 19:08:34 +03:00
|
|
|
]).test({
|
|
|
|
status: 1
|
|
|
|
});
|
2017-07-04 18:55:06 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("multiple patterns with non exists pattern", () => {
|
|
|
|
runPrettier("cli/multiple-patterns", [
|
2017-07-04 18:55:06 +03:00
|
|
|
"directory/**/*.js",
|
|
|
|
"non-existent.js",
|
|
|
|
"-l"
|
2017-10-02 19:08:34 +03:00
|
|
|
]).test({
|
|
|
|
status: 1
|
|
|
|
});
|
2017-07-04 18:55:06 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("multiple patterns with ignore nested directories pattern", () => {
|
|
|
|
runPrettier("cli/multiple-patterns", [
|
2017-07-04 18:55:06 +03:00
|
|
|
"**/*.js",
|
|
|
|
"!**/nested-directory/**",
|
|
|
|
"-l"
|
2017-10-02 19:08:34 +03:00
|
|
|
]).test({
|
|
|
|
status: 1
|
|
|
|
});
|
2017-07-04 18:55:06 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("multiple patterns by with ignore pattern, ignores node_modules by default", () => {
|
2017-11-07 11:42:38 +03:00
|
|
|
runPrettier("cli/multiple-patterns", ["**/*.js", "!directory/**", "-l"]).test(
|
|
|
|
{
|
|
|
|
status: 1
|
|
|
|
}
|
|
|
|
);
|
2017-07-04 18:55:06 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("multiple patterns by with ignore pattern, ignores node_modules by with ./**/*.js", () => {
|
|
|
|
runPrettier("cli/multiple-patterns", [
|
2017-07-04 18:55:06 +03:00
|
|
|
"./**/*.js",
|
|
|
|
"!./directory/**",
|
|
|
|
"-l"
|
2017-10-02 19:08:34 +03:00
|
|
|
]).test({
|
|
|
|
status: 1
|
|
|
|
});
|
2017-07-04 18:55:06 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("multiple patterns by with ignore pattern, doesn't ignore node_modules with --with-node-modules flag", () => {
|
|
|
|
runPrettier("cli/multiple-patterns", [
|
2017-07-04 18:55:06 +03:00
|
|
|
"**/*.js",
|
|
|
|
"!directory/**",
|
|
|
|
"-l",
|
|
|
|
"--with-node-modules"
|
2017-10-02 19:08:34 +03:00
|
|
|
]).test({
|
|
|
|
status: 1
|
|
|
|
});
|
2017-07-04 18:55:06 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("no errors on empty patterns", () => {
|
2018-05-23 22:55:06 +03:00
|
|
|
// --parser is mandatory if no filepath is passed
|
2018-12-27 16:05:19 +03:00
|
|
|
runPrettier("cli/multiple-patterns", ["--parser", "babel"]).test({
|
2017-10-02 19:08:34 +03:00
|
|
|
status: 0
|
|
|
|
});
|
2017-07-04 18:55:06 +03:00
|
|
|
});
|
|
|
|
|
2017-10-02 19:08:34 +03:00
|
|
|
describe("multiple patterns, throw error and exit with non zero code on non existing files", () => {
|
|
|
|
runPrettier("cli/multiple-patterns", [
|
2017-07-04 18:55:06 +03:00
|
|
|
"non-existent.js",
|
|
|
|
"other-non-existent.js",
|
|
|
|
"-l"
|
2017-10-02 19:08:34 +03:00
|
|
|
]).test({
|
|
|
|
status: 2
|
|
|
|
});
|
2017-07-04 18:55:06 +03:00
|
|
|
});
|