Passed
Push — master ( b7225f...73def0 )
by Andrii
03:04
created

sandbox/readline.test.ts   A

Complexity

Total Complexity 2
Complexity/F 0

Size

Lines of Code 26
Function Count 0

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 24
mnd 2
bc 2
fnc 0
dl 0
loc 26
bpm 0
cpm 0
noi 0
c 0
b 0
f 0
rs 10
1
import {createReadStream, readFileSync} from 'fs'
2
import {createInterface} from 'readline'
3
4
it("last empty", async () => {
5
  const filename = `${__dirname}/readline.last--empty.txt`
6
  , {length} = readFileSync(filename).toString().split("\n")
7
  , lineReader = createInterface(createReadStream(filename))
8
9
  let i = 0
10
  for await (const _ of lineReader)
11
    i++
12
13
  expect(i).toBe(length - 1)
14
})
15
16
it("last not empty", async () => {
17
  const filename = `${__dirname}/readline.last--not_empty.txt`
18
  , {length} = readFileSync(filename).toString().split("\n")
19
  , lineReader = createInterface(createReadStream(filename))
20
21
  let i = 0
22
  for await (const _ of lineReader)
23
    i++
24
25
  expect(i).toBe(length)
26
})