Total Complexity | 2 |
Complexity/F | 0 |
Lines of Code | 17 |
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, wait } from 'pepka' |
||
4 | import { test } from '../suite' |
||
5 | |||
6 | /** Lazy connect */ |
||
7 | test('lazy', timeout(2e3, async () => { |
||
8 | const {port} = await mockServer() |
||
9 | const ws = createNew({ lazy: true }, port) |
||
10 | |||
11 | await wait(500) |
||
12 | if(ws.socket !== null) throw new Error('Socket is not open.') |
||
13 | else { |
||
14 | const msg = {echo: true, msg: 'hello!'} |
||
15 | if(!equals(await ws.send(msg), msg)) throw new Error('msg\s not equal.') |
||
16 | } |
||
17 | })) |