Skip to content

Commit

Permalink
fix: add test for empty path
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv committed Dec 7, 2021
1 parent fd8e0aa commit dbb3e29
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions test/__snapshots__/validate-plugin-options.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ exports[`validate options should throw an error on the "attributes" option with
-> Read more at https://github.com/webpack-contrib/mini-css-extract-plugin#attributes"
`;

exports[`validate options should throw an error on the "chunkFilename" option with "" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
- options.chunkFilename should be a non-empty string."
`;

exports[`validate options should throw an error on the "chunkFilename" option with "/styles/[id].css" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
- options.chunkFilename: A relative path is expected. However, the provided value \\"/styles/[id].css\\" is an absolute path!"
Expand All @@ -24,6 +29,11 @@ exports[`validate options should throw an error on the "chunkFilename" option wi
* options.chunkFilename should be an instance of function."
`;

exports[`validate options should throw an error on the "filename" option with "" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
- options.filename should be a non-empty string."
`;

exports[`validate options should throw an error on the "filename" option with "/styles/[name].css" value 1`] = `
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
- options.filename: A relative path is expected. However, the provided value \\"/styles/[name].css\\" is an absolute path!"
Expand Down
4 changes: 2 additions & 2 deletions test/validate-plugin-options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ describe("validate options", () => {
"[name].css",
({ name }) => `${name.replace("/js/", "/css/")}.css`,
],
failure: [true, "/styles/[name].css"],
failure: [true, "/styles/[name].css", ""],
},
chunkFilename: {
success: ["[id].css", ({ chunk }) => `${chunk.id}.${chunk.name}.css`],
failure: [true, "/styles/[id].css"],
failure: [true, "/styles/[id].css", ""],
},
ignoreOrder: {
success: [true, false],
Expand Down

0 comments on commit dbb3e29

Please sign in to comment.