diff --git a/test/__fixtures__/error-on-unmatched-pattern/some.js b/test/__fixtures__/error-on-unmatched-pattern/some.js new file mode 100644 index 0000000..d91ae53 --- /dev/null +++ b/test/__fixtures__/error-on-unmatched-pattern/some.js @@ -0,0 +1 @@ +const hello = "there"; diff --git a/test/__fixtures__/error-on-unmatched-pattern/some.json b/test/__fixtures__/error-on-unmatched-pattern/some.json new file mode 100644 index 0000000..f7df04e --- /dev/null +++ b/test/__fixtures__/error-on-unmatched-pattern/some.json @@ -0,0 +1,3 @@ +{ + "hello": "there" +} diff --git a/test/__fixtures__/error-on-unmatched-pattern/some.yml b/test/__fixtures__/error-on-unmatched-pattern/some.yml new file mode 100644 index 0000000..611962c --- /dev/null +++ b/test/__fixtures__/error-on-unmatched-pattern/some.yml @@ -0,0 +1 @@ +hello: there diff --git a/test/__tests__/__snapshots__/error-on-unmatched-pattern.js.snap b/test/__tests__/__snapshots__/error-on-unmatched-pattern.js.snap new file mode 100644 index 0000000..ab48a0c --- /dev/null +++ b/test/__tests__/__snapshots__/error-on-unmatched-pattern.js.snap @@ -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`] = `[]`; diff --git a/test/__tests__/error-on-unmatched-pattern.js b/test/__tests__/error-on-unmatched-pattern.js new file mode 100644 index 0000000..30b8b68 --- /dev/null +++ b/test/__tests__/error-on-unmatched-pattern.js @@ -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, + }); +});