Total Complexity | 1 |
Complexity/F | 0 |
Lines of Code | 23 |
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 | /** Reconnects if connection is broken. */ |
||
7 | test('reconnect', timeout(1e4, () => new Promise<void>(async (ff, rj) => { |
||
8 | const {port, shutDown} = await mockServer() |
||
9 | const ws = createNew({ reconnect: 1 }, port) |
||
10 | |||
11 | setTimeout(async () => { |
||
12 | await shutDown() |
||
13 | setTimeout(async () => { |
||
14 | await mockServer(port) |
||
15 | setTimeout(async () => { |
||
16 | const msg = {echo: true, msg: 'hello!'} |
||
17 | const response = await ws.send(msg) |
||
18 | if(equals(response, msg)) ff(); else rj('not equals.') |
||
19 | }, 1500) |
||
20 | }, 1100) |
||
21 | }, 500) |
||
22 | }) |
||
23 | )) |