Skip to content

Commit

Permalink
[test] Fix failing tests
Browse files Browse the repository at this point in the history
Refs: e173423c
  • Loading branch information
lpinca committed Jan 9, 2022
1 parent 91f3c07 commit 8de448f
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions test/websocket.integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
Expand All @@ -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();
});
});
Expand Down

0 comments on commit 8de448f

Please sign in to comment.