Skip to content

Commit 23d2492

Browse files
committed
test: add validation tests
1 parent 475d659 commit 23d2492

File tree

3 files changed

+46
-0
lines changed

3 files changed

+46
-0
lines changed

test/__snapshots__/validate-options.test.js.snap.webpack4

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,27 @@ exports[`options validate should throw an error on the "server" option with '{"t
694694
-> Request for an SSL certificate."
695695
`;
696696

697+
exports[`options validate should throw an error on the "setupMiddlewares" option with '10' value 1`] = `
698+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
699+
- options.setupMiddlewares should be an instance of function.
700+
-> Provides the ability to execute a custom function and apply custom middleware(s).
701+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserversetupmiddlewares"
702+
`;
703+
704+
exports[`options validate should throw an error on the "setupMiddlewares" option with 'false' value 1`] = `
705+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
706+
- options.setupMiddlewares should be an instance of function.
707+
-> Provides the ability to execute a custom function and apply custom middleware(s).
708+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserversetupmiddlewares"
709+
`;
710+
711+
exports[`options validate should throw an error on the "setupMiddlewares" option with 'true' value 1`] = `
712+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
713+
- options.setupMiddlewares should be an instance of function.
714+
-> Provides the ability to execute a custom function and apply custom middleware(s).
715+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserversetupmiddlewares"
716+
`;
717+
697718
exports[`options validate should throw an error on the "static" option with '' value 1`] = `
698719
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
699720
- options.static should be a non-empty string."

test/__snapshots__/validate-options.test.js.snap.webpack5

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,27 @@ exports[`options validate should throw an error on the "server" option with '{"t
694694
-> Request for an SSL certificate."
695695
`;
696696

697+
exports[`options validate should throw an error on the "setupMiddlewares" option with '10' value 1`] = `
698+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
699+
- options.setupMiddlewares should be an instance of function.
700+
-> Provides the ability to execute a custom function and apply custom middleware(s).
701+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserversetupmiddlewares"
702+
`;
703+
704+
exports[`options validate should throw an error on the "setupMiddlewares" option with 'false' value 1`] = `
705+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
706+
- options.setupMiddlewares should be an instance of function.
707+
-> Provides the ability to execute a custom function and apply custom middleware(s).
708+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserversetupmiddlewares"
709+
`;
710+
711+
exports[`options validate should throw an error on the "setupMiddlewares" option with 'true' value 1`] = `
712+
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
713+
- options.setupMiddlewares should be an instance of function.
714+
-> Provides the ability to execute a custom function and apply custom middleware(s).
715+
-> Read more at https://webpack.js.org/configuration/dev-server/#devserversetupmiddlewares"
716+
`;
717+
697718
exports[`options validate should throw an error on the "static" option with '' value 1`] = `
698719
"ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
699720
- options.static should be a non-empty string."

test/validate-options.test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,10 @@ const tests = {
504504
},
505505
],
506506
},
507+
setupMiddlewares: {
508+
success: [() => {}],
509+
failure: [false, 10, "true"],
510+
},
507511
webSocketServer: {
508512
success: [
509513
false,

0 commit comments

Comments
 (0)