forked from c3js/c3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubchart-spec.ts
66 lines (56 loc) · 1.69 KB
/
subchart-spec.ts
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
61
62
63
64
65
66
import { initChart } from './c3-helper'
describe('c3 subchart', function() {
'use strict'
let chart
let args = {
data: {
x: 'date',
columns: [
[
'date',
'2012-12-24',
'2012-12-25',
'2012-12-26',
'2012-12-27',
'2012-12-28',
'2012-12-29'
],
['data1', 30, 200, -100, 400, -150, 250],
['data2', 50, 20, 10, 40, 15, 25]
],
groups: [['data1', 'data2']],
type: 'bar'
},
axis: {
x: {
type: 'category'
}
},
subchart: {
show: true
}
}
beforeEach(done => {
chart = initChart(chart, args, done)
})
const getChartHeight = () =>
+chart.internal.svg.select('.c3-event-rect').attr('height') - 1
describe('api', () => {
it('can toggle subchart visibility', () => {
const chartHeightWithSubchart = getChartHeight()
expect(chart.subchart.isShown()).toBeTruthy()
expect(chart.internal.svg.selectAll('.c3-axis-x').size()).toEqual(2)
expect(chart.internal.svg.selectAll('.c3-brush').size()).toEqual(1)
chart.subchart.hide()
expect(chart.subchart.isShown()).toBeFalsy()
expect(chart.internal.svg.selectAll('.c3-axis-x').size()).toEqual(1)
expect(chart.internal.svg.selectAll('.c3-brush').size()).toEqual(0)
expect(getChartHeight()).toBeGreaterThan(chartHeightWithSubchart)
chart.subchart.show()
expect(chart.subchart.isShown()).toBeTruthy()
expect(chart.internal.svg.selectAll('.c3-axis-x').size()).toEqual(2)
expect(chart.internal.svg.selectAll('.c3-brush').size()).toEqual(1)
expect(getChartHeight()).toEqual(chartHeightWithSubchart)
})
})
})