diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-21 11:44:51 +0000 |
commit | 9e3c08db40b8916968b9f30096c7be3f00ce9647 (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /testing/xpcshell/node-ws/test/websocket.integration.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | testing/xpcshell/node-ws/test/websocket.integration.js | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/testing/xpcshell/node-ws/test/websocket.integration.js b/testing/xpcshell/node-ws/test/websocket.integration.js new file mode 100644 index 0000000000..abd96c61e4 --- /dev/null +++ b/testing/xpcshell/node-ws/test/websocket.integration.js @@ -0,0 +1,55 @@ +'use strict'; + +const assert = require('assert'); + +const WebSocket = require('..'); + +describe('WebSocket', () => { + it('communicates successfully with echo service (ws)', (done) => { + const ws = new WebSocket('ws://websocket-echo.com/', { + protocolVersion: 13 + }); + + let dataReceived = false; + + ws.on('open', () => { + ws.send('hello'); + }); + + ws.on('close', () => { + assert.ok(dataReceived); + done(); + }); + + ws.on('message', (message, isBinary) => { + dataReceived = true; + assert.ok(!isBinary); + assert.strictEqual(message.toString(), 'hello'); + ws.close(); + }); + }); + + it('communicates successfully with echo service (wss)', (done) => { + const ws = new WebSocket('wss://websocket-echo.com/', { + protocolVersion: 13 + }); + + let dataReceived = false; + + ws.on('open', () => { + ws.send('hello'); + }); + + ws.on('close', () => { + assert.ok(dataReceived); + done(); + }); + + ws.on('message', (message, isBinary) => { + dataReceived = true; + assert.ok(!isBinary); + assert.strictEqual(message.toString(), 'hello'); + ws.close(); + }); + }); +}); |