From 3611a15c64dae6c953c65e7697a061fd5b3fedc7 Mon Sep 17 00:00:00 2001 From: Anshuman Verma Date: Wed, 26 May 2021 16:33:59 +0530 Subject: [PATCH] fix: more tests --- lib/options.json | 2 +- .../validate-options.test.js.snap.webpack4 | 2 +- .../validate-options.test.js.snap.webpack5 | 2 +- test/cli/cli.test.js | 48 ++++++++++++++++--- 4 files changed, 44 insertions(+), 10 deletions(-) diff --git a/lib/options.json b/lib/options.json index 38edbfbc01..3c1c2b278c 100644 --- a/lib/options.json +++ b/lib/options.json @@ -347,7 +347,7 @@ "minItems": 1 } ], - "description": "Defines routes which are enabled by default, on by default and allows localhost. https://webpack.js.org/configuration/dev-server/#devserverfirewall" + "description": "Defines routes which are enabled by default, on by default and allows localhost. https://webpack.js.org/configuration/dev-server/#devserverallowedhosts" }, "headers": { "anyOf": [ diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack4 b/test/__snapshots__/validate-options.test.js.snap.webpack4 index 70100f180c..2ceaa4771a 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack4 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack4 @@ -9,7 +9,7 @@ exports[`options validate should throw an error on the "allowedHosts" option wit "ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration.allowedHosts should be one of these: boolean | string | [string, ...] (should not have fewer than 1 item) - -> Defines routes which are enabled by default, on by default and allows localhost. https://webpack.js.org/configuration/dev-server/#devserverfirewall + -> Defines routes which are enabled by default, on by default and allows localhost. https://webpack.js.org/configuration/dev-server/#devserverallowedhosts Details: * configuration.allowedHosts should be a boolean. * configuration.allowedHosts should be a string. diff --git a/test/__snapshots__/validate-options.test.js.snap.webpack5 b/test/__snapshots__/validate-options.test.js.snap.webpack5 index 70100f180c..2ceaa4771a 100644 --- a/test/__snapshots__/validate-options.test.js.snap.webpack5 +++ b/test/__snapshots__/validate-options.test.js.snap.webpack5 @@ -9,7 +9,7 @@ exports[`options validate should throw an error on the "allowedHosts" option wit "ValidationError: Invalid configuration object. Object has been initialized using a configuration object that does not match the API schema. - configuration.allowedHosts should be one of these: boolean | string | [string, ...] (should not have fewer than 1 item) - -> Defines routes which are enabled by default, on by default and allows localhost. https://webpack.js.org/configuration/dev-server/#devserverfirewall + -> Defines routes which are enabled by default, on by default and allows localhost. https://webpack.js.org/configuration/dev-server/#devserverallowedhosts Details: * configuration.allowedHosts should be a boolean. * configuration.allowedHosts should be a string. diff --git a/test/cli/cli.test.js b/test/cli/cli.test.js index 5c6a268107..8ae766871a 100644 --- a/test/cli/cli.test.js +++ b/test/cli/cli.test.js @@ -654,13 +654,47 @@ describe('CLI', () => { .catch(done); }); - it('--allowed-hosts', (done) => { - testBin('--allowed-hosts') - .then((output) => { - expect(output.exitCode).toEqual(0); - done(); - }) - .catch(done); + describe('allowed-hosts', () => { + it('--allowed-hosts', (done) => { + testBin('--allowed-hosts') + .then((output) => { + expect(output.exitCode).toEqual(0); + done(); + }) + .catch(done); + }); + + it('--no-allowed-hosts', (done) => { + testBin('--no-allowed-hosts') + .then((output) => { + expect(output.exitCode).toEqual(0); + done(); + }) + .catch(done); + }); + + it('--allowed-hosts string', (done) => { + testBin('--allowed-hosts', 'testhost.com') + .then((output) => { + expect(output.exitCode).toEqual(0); + done(); + }) + .catch(done); + }); + + it('--allowed-hosts multiple', (done) => { + testBin( + '--allowed-hosts', + 'testhost.com', + '--allowed-hosts', + 'testhost1.com' + ) + .then((output) => { + expect(output.exitCode).toEqual(0); + done(); + }) + .catch(done); + }); }); it('--no-static-serve-index', (done) => {