Skip to content

Commit

Permalink
fix: more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anshumanv committed May 26, 2021
1 parent af628d7 commit 3611a15
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 10 deletions.
2 changes: 1 addition & 1 deletion lib/options.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/validate-options.test.js.snap.webpack4
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion test/__snapshots__/validate-options.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
48 changes: 41 additions & 7 deletions test/cli/cli.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down

0 comments on commit 3611a15

Please sign in to comment.