Skip to content

Commit

Permalink
Ported test suite: error-no-unmatched-pattern
Browse files Browse the repository at this point in the history
- Errors are thrown if no results are found for every glob, not any glob.
  • Loading branch information
fabiospampinato committed Sep 15, 2024
1 parent 13825b8 commit 51c4400
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 0 deletions.
1 change: 1 addition & 0 deletions test/__fixtures__/error-on-unmatched-pattern/some.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const hello = "there";
3 changes: 3 additions & 0 deletions test/__fixtures__/error-on-unmatched-pattern/some.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"hello": "there"
}
1 change: 1 addition & 0 deletions test/__fixtures__/error-on-unmatched-pattern/some.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
hello: there
37 changes: 37 additions & 0 deletions test/__tests__/__snapshots__/error-on-unmatched-pattern.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`error on unmatched pattern (stderr) 1`] = `"[error] No files matching the given patterns were found"`;

exports[`error on unmatched pattern (stdout) 1`] = `""`;

exports[`error on unmatched pattern (write) 1`] = `[]`;

exports[`error on unmatched pattern when 2nd glob has no match, by default (stderr) 1`] = `""`;

exports[`error on unmatched pattern when 2nd glob has no match, by default (stdout) 1`] = `
"const hello = "there";
{
"hello": "there"
}
hello: there"
`;

exports[`error on unmatched pattern when 2nd glob has no match, by default (write) 1`] = `[]`;

exports[`no error on unmatched pattern (stderr) 1`] = `""`;

exports[`no error on unmatched pattern (stdout) 1`] = `"const hello = "there";"`;

exports[`no error on unmatched pattern (write) 1`] = `[]`;

exports[`no error on unmatched pattern when 2nd glob has no match, with flag (stderr) 1`] = `""`;

exports[`no error on unmatched pattern when 2nd glob has no match, with flag (stdout) 1`] = `
"const hello = "there";
{
"hello": "there"
}
hello: there"
`;

exports[`no error on unmatched pattern when 2nd glob has no match, with flag (write) 1`] = `[]`;
37 changes: 37 additions & 0 deletions test/__tests__/error-on-unmatched-pattern.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { runCli } from "../utils";

describe("no error on unmatched pattern", () => {
runCli("error-on-unmatched-pattern", [
"--no-error-on-unmatched-pattern",
"**/*.js",
]).test({
status: 0,
});
});

describe("error on unmatched pattern", () => {
runCli("error-on-unmatched-pattern", [
"**/*.toml",
]).test({
status: 1,
});
});

describe("no error on unmatched pattern when 2nd glob has no match, with flag", () => {
runCli("error-on-unmatched-pattern", [
"--no-error-on-unmatched-pattern",
"**/*.{json,js,yml}",
"**/*.toml",
]).test({
status: 0,
});
});

describe("error on unmatched pattern when 2nd glob has no match, by default", () => {
runCli("error-on-unmatched-pattern", [
"**/*.{json,js,yml}",
"**/*.toml",
]).test({
status: 0,
});
});

0 comments on commit 51c4400

Please sign in to comment.