Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 19 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { createNew } from '../utils.js' |
||
2 | import mockServer from '../mock/server.js' |
||
3 | import { equals } from 'pepka' |
||
4 | import { test } from '../suite.js' |
||
5 | |||
6 | /** Sends massages if they were .send() before connection is estabilished. */ |
||
7 | test('lazy send before open queued.', () => new Promise(async (ff, rj) => { |
||
8 | const {port} = await mockServer() |
||
9 | let to = setTimeout(() => rj('cannot create'), 2e2) |
||
10 | const ws = createNew({lazy: true}, port) |
||
11 | clearTimeout(to) |
||
12 | |||
13 | const msg = {echo: true, msg: 'hello!'} |
||
14 | to = setTimeout(() => rj('cannot send'), 2e2) |
||
15 | const response = await ws.send(msg) |
||
16 | clearTimeout(to) |
||
17 | |||
18 | if(equals(response, msg)) ff(); else rj() |
||
19 | })) |