Passed
Push — master ( b0ae8b...67a8ba )
by Michael
01:38
created

test/specs/lazy-send-before-open.ts   A

Complexity

Total Complexity 1
Complexity/F 0

Size

Lines of Code 19
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 17
mnd 1
bc 1
fnc 0
dl 0
loc 19
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 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
}))