-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
42 lines (36 loc) · 867 Bytes
/
test.js
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
'use strict'
const { deepStrictEqual, doesNotThrow } = require('assert')
const computeLayout = require('.')
// ---A---
// -----B------
// --C--
// ----D--
// -E-
const sections = [
[2, ['A' ]],
[3, ['A', 'B' ]],
[2, ['A', 'B', 'C' ]],
[1, [ 'B', 'C' ]],
[2, [ 'B', 'C', 'D' ]],
[1, [ 'B', 'D' ]],
[3, [ 'B', 'D', 'E']],
[1, [ 'D' ]]
]
const ___ = null
deepStrictEqual(computeLayout(sections), [
[2, ['A']],
[3, ['A', 'B']],
[2, ['A', 'B', 'C']],
[1, [___, 'B', 'C']],
[2, ['D', 'B', 'C']],
[1, ['D', 'B', ___]],
[3, ['D', 'B', 'E']],
[1, ['D', ___, ___]],
])
// works with ranges that are not primitive types
doesNotThrow(() => {
computeLayout([
[1, [{foo: 'bar'}]]
])
})
console.info('tests successful ✔︎')