test/specs/lazy.ts   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 0

Size

Lines of Code 17
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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