Skip to content

Commit

Permalink
[test] Do not call duplex.end() prematurely
Browse files Browse the repository at this point in the history
Keep the `WebSocket` connection open while the test is run.

Refs: nodejs/node#32780
  • Loading branch information
lpinca committed Apr 22, 2020
1 parent 651d662 commit 3730467
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions test/create-websocket-stream.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ describe('createWebSocketStream', () => {
ws._receiver.on('drain', () => {
called.push('drain');
assert.ok(!ws._socket.isPaused());
duplex.end();
});

const list = Sender.frame(randomBytes(16 * 1024), {
Expand All @@ -429,7 +430,6 @@ describe('createWebSocketStream', () => {
ws._socket.push(Buffer.concat(list));
});

duplex.on('resume', duplex.end);
duplex.on('close', () => {
assert.deepStrictEqual(called, ['read', 'drain']);
wss.close(done);
Expand All @@ -450,6 +450,7 @@ describe('createWebSocketStream', () => {
assert.ok(!ws._receiver._writableState.needDrain);
read();
assert.ok(!ws._socket.isPaused());
duplex.end();
};

ws.on('open', () => {
Expand All @@ -470,7 +471,6 @@ describe('createWebSocketStream', () => {
ws._socket.push(Buffer.concat(list));
});

duplex.on('resume', duplex.end);
duplex.on('close', () => {
assert.deepStrictEqual(called, ['drain', 'read']);
wss.close(done);
Expand Down

0 comments on commit 3730467

Please sign in to comment.