1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
const test = require('tape')
const unitsToRanges = require('../lib/unitsToRanges.js')
test('units list to addr:flats', t => {
t.same(
unitsToRanges([]),
null,
'empty input returns empty output'
)
t.same(
unitsToRanges(['1'], 100),
'1',
'single unit'
)
t.same(
unitsToRanges(['1', '3']),
'1;3',
'two units without a range'
)
t.same(
unitsToRanges(['1', '2']),
'1-2',
'two consecutive units form a range'
)
t.same(
unitsToRanges(['1', '2', '3']),
'1-3',
'three consecutive units form a range'
)
t.same(
unitsToRanges(['1', '2', '4']),
'1-2;4',
'range and singular'
)
t.end()
})
|