|
2 | 2 |
|
3 | 3 | const path = require('path');
|
4 | 4 | const request = require('supertest');
|
| 5 | +const internalIp = require('internal-ip'); |
5 | 6 | const config = require('../fixtures/simple-config/webpack.config');
|
6 | 7 | const testServer = require('../helpers/test-server');
|
7 | 8 | const port = require('../ports-map')['host-option'];
|
@@ -200,4 +201,68 @@ describe('host option', () => {
|
200 | 201 |
|
201 | 202 | afterAll(testServer.close);
|
202 | 203 | });
|
| 204 | + |
| 205 | + describe('is local-ip', () => { |
| 206 | + beforeAll((done) => { |
| 207 | + server = testServer.start( |
| 208 | + config, |
| 209 | + { |
| 210 | + static: { |
| 211 | + directory: staticDirectory, |
| 212 | + watch: false, |
| 213 | + }, |
| 214 | + host: 'local-ip', |
| 215 | + port, |
| 216 | + }, |
| 217 | + done |
| 218 | + ); |
| 219 | + req = request(server.app); |
| 220 | + }); |
| 221 | + |
| 222 | + it('server address', () => { |
| 223 | + const address = server.server.address(); |
| 224 | + const networkIP = internalIp.v4.sync(); |
| 225 | + |
| 226 | + expect(address.address).toBe(networkIP); |
| 227 | + expect(address.port).toBe(port); |
| 228 | + }); |
| 229 | + |
| 230 | + it('Request to index', (done) => { |
| 231 | + req.get('/').expect(200, done); |
| 232 | + }); |
| 233 | + |
| 234 | + afterAll(testServer.close); |
| 235 | + }); |
| 236 | + |
| 237 | + describe('is local-ipv4', () => { |
| 238 | + beforeAll((done) => { |
| 239 | + server = testServer.start( |
| 240 | + config, |
| 241 | + { |
| 242 | + static: { |
| 243 | + directory: staticDirectory, |
| 244 | + watch: false, |
| 245 | + }, |
| 246 | + host: 'local-ipv4', |
| 247 | + port, |
| 248 | + }, |
| 249 | + done |
| 250 | + ); |
| 251 | + req = request(server.app); |
| 252 | + }); |
| 253 | + |
| 254 | + it('server address', () => { |
| 255 | + const address = server.server.address(); |
| 256 | + const networkIP = internalIp.v4.sync(); |
| 257 | + |
| 258 | + expect(address.address).toBe(networkIP); |
| 259 | + expect(address.port).toBe(port); |
| 260 | + }); |
| 261 | + |
| 262 | + it('Request to index', (done) => { |
| 263 | + req.get('/').expect(200, done); |
| 264 | + }); |
| 265 | + |
| 266 | + afterAll(testServer.close); |
| 267 | + }); |
203 | 268 | });
|
0 commit comments