-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
60 lines (58 loc) · 787 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import test from 'ava';
import leaderlines from './index.js';
test('title', t => {
const data = [
{y1: 10, y2: 3},
{y1: 15, y2: 5},
{y1: 20, y2: 20},
{y1: 25, y2: 28},
{y1: 26, y2: 35},
{y1: 50, y2: 52}
];
const expected = [
{
x1: 10,
x2: 22.5,
x3: 30,
y1: 10,
y2: 3
},
{
x1: 10,
x2: 25.5,
x3: 30,
y1: 15,
y2: 5
},
{
x1: 10,
x2: 24,
x3: 30,
y1: 20,
y2: 20
},
{
x1: 10,
x2: 25.5,
x3: 30,
y1: 25,
y2: 28
},
{
x1: 10,
x2: 22.5,
x3: 30,
y1: 26,
y2: 35
},
{
x1: 10,
x2: 24,
x3: 30,
y1: 50,
y2: 52
}
];
const config = {xRange: [10, 30], middleX2: 24, targetGap: 3, maxSumOfGaps: 7};
t.deepEqual(leaderlines(data, config, d => d.y1, d => d.y2), expected);
});