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