Skip to content

Commit

Permalink
refactor: update snapshot & change clientSocketOptions type to Object
Browse files Browse the repository at this point in the history
  • Loading branch information
EslamHiko committed Sep 25, 2019
1 parent ff8b981 commit a2a5102
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 22 deletions.
33 changes: 17 additions & 16 deletions lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,24 @@
"enum": ["info", "warn", "error", "debug", "trace", "silent"]
},
"clientSocketOptions": {
"anyOf": [
{
"type": "array"
"type": "object",
"properties": {
"host": {
"type": "string"
},
{
"type": "object"
"path": {
"type": "string"
},
"port": {
"anyOf": [
{
"type": "string"
},
{
"type": "number"
}
]
}
],
"items": {
"anyOf": [
{
"type": "number"
},
{
"type": "string"
}
]
}
},
"compress": {
Expand Down Expand Up @@ -404,7 +405,7 @@
"ca": "should be {String|Buffer}",
"cert": "should be {String|Buffer}",
"clientLogLevel": "should be {String} and equal to one of the allowed values\n\n [ 'silent', 'info', 'debug', 'trace', 'error', 'warn' ]\n\n (https://webpack.js.org/configuration/dev-server/#devserverclientloglevel)",
"clientSocketOptions": "should be {Array} (https://webpack.js.org/configuration/dev-server/#devserverclientsocketoptions)",
"clientSocketOptions": "should be {Object} (https://webpack.js.org/configuration/dev-server/#devserverclientsocketoptions)",
"compress": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devservercompress)",
"contentBase": "should be {Number|String|Array} (https://webpack.js.org/configuration/dev-server/#devservercontentbase)",
"disableHostCheck": "should be {Boolean} (https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck)",
Expand Down
2 changes: 1 addition & 1 deletion lib/utils/createConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function createConfig(config, argv, { port }) {
(argv.sockHost || argv.sockPath || argv.sockPort) &&
!options.clientSocketOptions
) {
options.clientSocketOptions = [];
options.clientSocketOptions = {};
}

if (argv.sockHost) {
Expand Down
4 changes: 2 additions & 2 deletions test/options.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ describe('options', () => {
failure: [false],
},
clientSocketOptions: {
success: [[], ['']],
failure: [[false], false],
success: [{}],
failure: [false],
},
staticOptions: {
success: [{}],
Expand Down
12 changes: 9 additions & 3 deletions test/server/utils/__snapshots__/createConfig.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1202,12 +1202,14 @@ Object {

exports[`createConfig sockHost option 1`] = `
Object {
"clientSocketOptions": Object {
"host": true,
},
"hot": true,
"hotOnly": false,
"noInfo": true,
"port": 8080,
"publicPath": "/",
"sockHost": true,
"stats": Object {
"cached": false,
"cachedAssets": false,
Expand All @@ -1217,12 +1219,14 @@ Object {

exports[`createConfig sockPath option 1`] = `
Object {
"clientSocketOptions": Object {
"path": "path",
},
"hot": true,
"hotOnly": false,
"noInfo": true,
"port": 8080,
"publicPath": "/",
"sockPath": "path",
"stats": Object {
"cached": false,
"cachedAssets": false,
Expand All @@ -1232,12 +1236,14 @@ Object {

exports[`createConfig sockPort option 1`] = `
Object {
"clientSocketOptions": Object {
"port": "port",
},
"hot": true,
"hotOnly": false,
"noInfo": true,
"port": 8080,
"publicPath": "/",
"sockPort": "port",
"stats": Object {
"cached": false,
"cachedAssets": false,
Expand Down

0 comments on commit a2a5102

Please sign in to comment.