From 8de448fbd105deeecada886344ca58237d423a8c Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Sun, 9 Jan 2022 16:10:24 +0100 Subject: [PATCH] [test] Fix failing tests Refs: https://github.com/websockets/ws/commit/e173423c --- test/websocket.integration.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/test/websocket.integration.js b/test/websocket.integration.js index e1fe7f558..abd96c61e 100644 --- a/test/websocket.integration.js +++ b/test/websocket.integration.js @@ -9,18 +9,22 @@ describe('WebSocket', () => { const ws = new WebSocket('ws://websocket-echo.com/', { protocolVersion: 13 }); - const str = Date.now().toString(); let dataReceived = false; - ws.on('open', () => ws.send(str)); + ws.on('open', () => { + ws.send('hello'); + }); + ws.on('close', () => { assert.ok(dataReceived); done(); }); - ws.on('message', (data) => { + + ws.on('message', (message, isBinary) => { dataReceived = true; - assert.strictEqual(data, str); + assert.ok(!isBinary); + assert.strictEqual(message.toString(), 'hello'); ws.close(); }); }); @@ -29,18 +33,22 @@ describe('WebSocket', () => { const ws = new WebSocket('wss://websocket-echo.com/', { protocolVersion: 13 }); - const str = Date.now().toString(); let dataReceived = false; - ws.on('open', () => ws.send(str)); + ws.on('open', () => { + ws.send('hello'); + }); + ws.on('close', () => { assert.ok(dataReceived); done(); }); - ws.on('message', (data) => { + + ws.on('message', (message, isBinary) => { dataReceived = true; - assert.strictEqual(data, str); + assert.ok(!isBinary); + assert.strictEqual(message.toString(), 'hello'); ws.close(); }); });