-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathrelease.test.ts
More file actions
86 lines (76 loc) · 1.8 KB
/
Copy pathrelease.test.ts
File metadata and controls
86 lines (76 loc) · 1.8 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import type { IBarChartSpec } from '../../../../src';
import VChart from '../../../../src';
import { createDiv, removeDom } from '../../../util/dom';
const dataSpecs = [1, 2].map(value => ({
data: [
{
id: 'data',
values: [{ country: 'USA', value }]
}
]
}));
const createSpec = (): IBarChartSpec =>
({
type: 'bar',
width: 300,
height: 220,
data: dataSpecs[0].data,
direction: 'horizontal',
yField: 'country',
xField: 'value',
player: {
type: 'continuous',
orient: 'bottom',
auto: true,
loop: true,
interval: 1000,
specs: dataSpecs,
slider: {
railStyle: {
height: 6
}
},
controller: {
backward: {
style: {
size: 12
}
},
forward: {
style: {
size: 12
}
},
start: {
order: 1,
position: 'end'
}
}
}
} as unknown as IBarChartSpec);
describe('player component release', () => {
let container: HTMLElement;
let dom: HTMLElement;
beforeEach(() => {
container = createDiv();
dom = createDiv(container);
container.style.width = '300px';
container.style.height = '220px';
});
afterEach(() => {
removeDom(container);
});
it('pauses the VRender player and runs base component cleanup', () => {
const chart = new VChart(createSpec(), {
dom,
animation: false
});
chart.renderSync();
const playerModel = chart.getChart()?.getComponentsByKey('player')[0] as any;
const playerComponent = playerModel?._playerComponent;
const pauseSpy = jest.spyOn(playerComponent, 'pause');
chart.release();
expect(pauseSpy).toHaveBeenCalledTimes(1);
expect(playerModel.getOption()).toBeNull();
});
});