Total Complexity | 2 |
Complexity/F | 0 |
Lines of Code | 22 |
Function Count | 0 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { createNew, timeout } from '../utils' |
||
2 | import mockServer from '../mock/server' |
||
3 | import { equals } from 'pepka' |
||
4 | import { test } from '../suite' |
||
5 | |||
6 | /** Lazy connect */ |
||
7 | test('lazy', timeout(2e3, () => { |
||
8 | return new Promise<void>(async (ff, rj) => { |
||
9 | const {port} = await mockServer() |
||
10 | const ws = createNew({ lazy: true }, port) |
||
11 | |||
12 | setTimeout(async () => { |
||
13 | if(ws.socket !== null) { |
||
14 | rj() |
||
15 | } else { |
||
16 | const msg = {echo: true, msg: 'hello!'} |
||
17 | const response = await ws.send(msg) |
||
18 | if(equals(response, msg)) ff(); else rj() |
||
19 | } |
||
20 | }, 500) |
||
21 | }) |
||
22 | })) |