From 23acf8cfaff73fadf89c69be669b3baa29b60233 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Fri, 10 Mar 2023 16:00:24 +0100 Subject: [PATCH] [test] Fix nits --- test/websocket.test.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/test/websocket.test.js b/test/websocket.test.js index f80acd3d5..cb5b434c0 100644 --- a/test/websocket.test.js +++ b/test/websocket.test.js @@ -3860,16 +3860,18 @@ describe('WebSocket', () => { it('honors the `finishRequest` option', (done) => { const wss = new WebSocket.Server({ port: 0 }, () => { - const ws = new WebSocket(`ws://localhost:${wss.address().port}`, { - finishRequest(request, websocket) { - process.nextTick(() => { - assert.strictEqual(request, ws._req); - assert.strictEqual(websocket, ws); - }); - request.on('socket', (socket) => { + const host = `localhost:${wss.address().port}`; + const ws = new WebSocket(`ws://${host}`, { + finishRequest(req, ws) { + assert.ok(req instanceof http.ClientRequest); + assert.strictEqual(req.getHeader('host'), host); + assert.ok(ws instanceof WebSocket); + assert.strictEqual(req, ws._req); + + req.on('socket', (socket) => { socket.on('connect', () => { - request.setHeader('Cookie', 'foo=bar'); - request.end(); + req.setHeader('Cookie', 'foo=bar'); + req.end(); }); }); }