add test case for enum validation
This commit is contained in:
parent
f1df013150
commit
0963d744e9
|
@ -154,6 +154,10 @@ class WebpackOptionsValidationError extends WebpackError {
|
|||
return "RegExp";
|
||||
}
|
||||
|
||||
if (schema.enum) {
|
||||
return schema.enum.map(item => JSON.stringify(item)).join(" | ");
|
||||
}
|
||||
|
||||
if (schema.$ref) {
|
||||
return formatInnerSchema(getSchemaPart(schema.$ref), true);
|
||||
}
|
||||
|
@ -166,9 +170,6 @@ class WebpackOptionsValidationError extends WebpackError {
|
|||
if (schema.anyOf) {
|
||||
return schema.anyOf.map(formatInnerSchema).join(" | ");
|
||||
}
|
||||
if (schema.enum) {
|
||||
return schema.enum.map(item => JSON.stringify(item)).join(" | ");
|
||||
}
|
||||
return JSON.stringify(schema, null, 2);
|
||||
}
|
||||
|
||||
|
@ -250,6 +251,7 @@ class WebpackOptionsValidationError extends WebpackError {
|
|||
err.parentSchema
|
||||
)}`;
|
||||
} else if (err.keyword === "enum") {
|
||||
console.log(err.parentSchema);
|
||||
if (
|
||||
err.parentSchema &&
|
||||
err.parentSchema.enum &&
|
||||
|
|
|
@ -458,6 +458,20 @@ describe("Validation", () => {
|
|||
-> The run point of the plugin, required method.
|
||||
* configuration.plugins[0] should be an instance of function
|
||||
-> Function acting as plugin"
|
||||
`)
|
||||
);
|
||||
|
||||
createTestCase(
|
||||
"invalid mode",
|
||||
{
|
||||
mode: "protuction"
|
||||
},
|
||||
msg =>
|
||||
expect(msg).toMatchInlineSnapshot(`
|
||||
"Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
|
||||
- configuration.mode should be one of these:
|
||||
\\"development\\" | \\"production\\" | \\"none\\"
|
||||
-> Enable production optimizations or development hints."
|
||||
`)
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue