From dbb3e295cda7c8cd01421367a46350ae8bb04900 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Tue, 7 Dec 2021 21:32:37 +0530 Subject: [PATCH] fix: add test for empty path --- .../__snapshots__/validate-plugin-options.test.js.snap | 10 ++++++++++ test/validate-plugin-options.test.js | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/test/__snapshots__/validate-plugin-options.test.js.snap b/test/__snapshots__/validate-plugin-options.test.js.snap index 1973e41e..ff8fb308 100644 --- a/test/__snapshots__/validate-plugin-options.test.js.snap +++ b/test/__snapshots__/validate-plugin-options.test.js.snap @@ -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!" @@ -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!" diff --git a/test/validate-plugin-options.test.js b/test/validate-plugin-options.test.js index 7ace0d98..ff95fbfc 100644 --- a/test/validate-plugin-options.test.js +++ b/test/validate-plugin-options.test.js @@ -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],