test/specs/close.ts   A
last analyzed

Complexity

Total Complexity 2
Complexity/F 0

Size

Lines of Code 18
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 18
rs 10
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
1
import { test } from '../suite'
2
import { createNew } from '../utils.js'
3
import mockServer from '../mock/server'
4
5
/** Closes the connenction. */
6
test('close', () => new Promise<void>(async (ff, rj) => {
7
  const {port} = await mockServer()
8
  const ws = await createNew({}, port)
9
10
  setTimeout(async () => {
11
    try {
12
      await ws.close()
13
      if(ws.socket === null) ff(); else rj()
14
    } catch(e) {
15
      rj()
16
    }
17
  }, 500)
18
}))