Skip to content

Commit

Permalink
test: 增加单测,保证"开启中心文本交互时,显式注册 tooltip 交互可以开启 tooltip"
Browse files Browse the repository at this point in the history
  • Loading branch information
visiky committed Dec 19, 2020
1 parent 13a9819 commit 8a3ec80
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions __tests__/bugs/issue-2096-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { Pie } from '../../src';
import { createDiv } from '../utils/dom';

describe('#2096', () => {
const pie = new Pie(createDiv(), {
data: [
{ type: '1', value: 10 },
{ type: '13', value: 10 },
{ type: '55', value: 10 },
],
angleField: 'value',
colorField: 'type',
radius: 0.8,
});

it('normal', () => {
pie.render();
expect(pie.chart.interactions.tooltip).toBeDefined();
});

it('开启中心文本交互时,默认关闭 tooltip', () => {
pie.update({
innerRadius: 0.64,
statistic: {},
interactions: [{ type: 'pie-statistic-active' }],
});

expect(pie.chart.interactions.tooltip).not.toBeDefined();
});

it('开启中心文本交互时,需要显式注册 tooltip 交互来开启 tooltip', () => {
pie.update({
interactions: [{ type: 'pie-statistic-active' }, { type: 'tooltip' }],
});
expect(pie.chart.interactions.tooltip).toBeDefined();
});
});

0 comments on commit 8a3ec80

Please sign in to comment.