Skip to content

Commit

Permalink
[test] Fix nits
Browse files Browse the repository at this point in the history
  • Loading branch information
lpinca committed Feb 4, 2022
1 parent e1ddacc commit 75fdfa9
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions test/websocket.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1101,11 +1101,9 @@ describe('WebSocket', () => {
});

it('emits an error if the redirect URL is invalid (1/2)', (done) => {
const onUpgrade = (req, socket) => {
server.once('upgrade', (req, socket) => {
socket.end('HTTP/1.1 302 Found\r\nLocation: ws://\r\n\r\n');
};

server.on('upgrade', onUpgrade);
});

const ws = new WebSocket(`ws://localhost:${server.address().port}`, {
followRedirects: true
Expand All @@ -1117,17 +1115,14 @@ describe('WebSocket', () => {
assert.strictEqual(err.message, 'Invalid URL: ws://');
assert.strictEqual(ws._redirects, 1);

server.removeListener('upgrade', onUpgrade);
ws.on('close', () => done());
});
});

it('emits an error if the redirect URL is invalid (2/2)', (done) => {
const onUpgrade = (req, socket) => {
server.once('upgrade', (req, socket) => {
socket.end('HTTP/1.1 302 Found\r\nLocation: http://localhost\r\n\r\n');
};

server.on('upgrade', onUpgrade);
});

const ws = new WebSocket(`ws://localhost:${server.address().port}`, {
followRedirects: true
Expand All @@ -1142,7 +1137,6 @@ describe('WebSocket', () => {
);
assert.strictEqual(ws._redirects, 1);

server.removeListener('upgrade', onUpgrade);
ws.on('close', () => done());
});
});
Expand Down

0 comments on commit 75fdfa9

Please sign in to comment.