97 lines
2.3 KiB
JavaScript
97 lines
2.3 KiB
JavaScript
"use strict";
|
|
|
|
const runPrettier = require("../runPrettier");
|
|
|
|
expect.addSnapshotSerializer(require("../path-serializer"));
|
|
|
|
describe("multiple patterns", () => {
|
|
runPrettier("cli/patterns", [
|
|
"directory/**/*.js",
|
|
"other-directory/**/*.js",
|
|
"-l"
|
|
]).test({
|
|
status: 1
|
|
});
|
|
});
|
|
|
|
describe("multiple patterns with non exists pattern", () => {
|
|
runPrettier("cli/patterns", [
|
|
"directory/**/*.js",
|
|
"non-existent.js",
|
|
"-l"
|
|
]).test({
|
|
status: 1
|
|
});
|
|
});
|
|
|
|
describe("multiple patterns with ignore nested directories pattern", () => {
|
|
runPrettier("cli/patterns", [
|
|
"**/*.js",
|
|
"!**/nested-directory/**",
|
|
"-l"
|
|
]).test({
|
|
status: 1
|
|
});
|
|
});
|
|
|
|
describe("multiple patterns by with ignore pattern, ignores node_modules by default", () => {
|
|
runPrettier("cli/patterns", ["**/*.js", "!directory/**", "-l"]).test({
|
|
status: 1
|
|
});
|
|
});
|
|
|
|
describe("multiple patterns by with ignore pattern, ignores node_modules by with ./**/*.js", () => {
|
|
runPrettier("cli/patterns", ["./**/*.js", "!./directory/**", "-l"]).test({
|
|
status: 1
|
|
});
|
|
});
|
|
|
|
describe("multiple patterns by with ignore pattern, doesn't ignore node_modules with --with-node-modules flag", () => {
|
|
runPrettier("cli/patterns", [
|
|
"**/*.js",
|
|
"!directory/**",
|
|
"-l",
|
|
"--with-node-modules"
|
|
]).test({
|
|
status: 1
|
|
});
|
|
});
|
|
|
|
describe("no errors on empty patterns", () => {
|
|
// --parser is mandatory if no filepath is passed
|
|
runPrettier("cli/patterns", ["--parser", "babel"]).test({
|
|
status: 0
|
|
});
|
|
});
|
|
|
|
describe("multiple patterns, throw error and exit with non zero code on non existing files", () => {
|
|
runPrettier("cli/patterns", [
|
|
"non-existent.js",
|
|
"other-non-existent.js",
|
|
"-l"
|
|
]).test({
|
|
status: 2
|
|
});
|
|
});
|
|
|
|
// the following 3 tests make sure we don't support broken
|
|
// `dot pattern` and `expand directories` implementation
|
|
// see https://github.com/prettier/prettier/pull/6639#issuecomment-548949954
|
|
describe("should not support dot pattern", () => {
|
|
runPrettier("cli/patterns", [".", "-l"]).test({
|
|
status: 2
|
|
});
|
|
});
|
|
|
|
describe("should not expand directories", () => {
|
|
runPrettier("cli/patterns", ["directory", "other-directory", "-l"]).test({
|
|
status: 2
|
|
});
|
|
});
|
|
|
|
describe("directories and patterns", () => {
|
|
runPrettier("cli/patterns", ["directory", "other-directory/**", "-l"]).test({
|
|
status: 1
|
|
});
|
|
});
|