/
distribution.test.js
54 lines (52 loc) · 1.3 KB
/
distribution.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
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/
import { getFormattedBuckets } from '../index';
describe('Distribution', () => {
it('getFormattedBuckets', () => {
const buckets = [
{ key: 0, count: 0 },
{ key: 20, count: 0 },
{ key: 40, count: 0 },
{
key: 60,
count: 5,
sample: {
transactionId: 'someTransactionId'
}
},
{
key: 80,
count: 100,
sample: {
transactionId: 'anotherTransactionId'
}
}
];
expect(getFormattedBuckets(buckets, 20)).toEqual([
{ x: 20, x0: 0, y: 0, style: { cursor: 'default' } },
{ x: 40, x0: 20, y: 0, style: { cursor: 'default' } },
{ x: 60, x0: 40, y: 0, style: { cursor: 'default' } },
{
x: 80,
x0: 60,
y: 5,
sample: {
transactionId: 'someTransactionId'
},
style: { cursor: 'pointer' }
},
{
x: 100,
x0: 80,
y: 100,
sample: {
transactionId: 'anotherTransactionId'
},
style: { cursor: 'pointer' }
}
]);
});
});