Skip to content

Commit 51cedf0

Browse files
committed
test: more
1 parent 196341d commit 51cedf0

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

lib/Server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ class Server {
750750
}
751751
}
752752

753-
listen(port, hostname, fn) {
753+
listen(port, hostname = this.options.host, fn) {
754754
if (
755755
typeof this.options.host !== 'undefined' &&
756756
hostname !== this.options.host

test/server/Server.test.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ jest.mock('sockjs/lib/transport');
1212

1313
const baseDevConfig = {
1414
port,
15-
host: 'localhost',
1615
static: false,
1716
};
1817

@@ -137,6 +136,10 @@ describe('Server', () => {
137136
compiler = webpack(config);
138137
});
139138

139+
afterEach((done) => {
140+
server.close(done);
141+
});
142+
140143
it('should listen and not throw error', (done) => {
141144
const options = {
142145
host: 'localhost',
@@ -148,6 +151,17 @@ describe('Server', () => {
148151
server.close(done);
149152
});
150153

154+
it('should work and listen', (done) => {
155+
const options = {
156+
host: 'localhost',
157+
};
158+
159+
server = new Server(compiler, options);
160+
161+
expect(() => server.listen(port)).not.toThrowError();
162+
server.close(done);
163+
});
164+
151165
it('should throw an error', (done) => {
152166
const options = {
153167
host: '192.160.21.34',

0 commit comments

Comments
 (0)