From afb877f36b8c973b3dc1c27066cdddf01678cfa1 Mon Sep 17 00:00:00 2001 From: simaQ Date: Tue, 17 Mar 2020 16:35:51 +0800 Subject: [PATCH] =?UTF-8?q?test(tooltip):=20=E6=B7=BB=E5=8A=A0=20tooltip?= =?UTF-8?q?=20=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/bugs/2174-spec.ts | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 tests/bugs/2174-spec.ts diff --git a/tests/bugs/2174-spec.ts b/tests/bugs/2174-spec.ts new file mode 100644 index 0000000000..7ed26c2968 --- /dev/null +++ b/tests/bugs/2174-spec.ts @@ -0,0 +1,49 @@ +import { Chart } from '../../src'; +import { createDiv } from '../util/dom'; + +describe('#2174, #2175', () => { + it('tooltip', () => { + const data = [ + { name: 'London', 月份: 'Jan.', 月均降雨量: 18.9 }, + ]; + + const chart = new Chart({ + container: createDiv(), + width: 400, + height: 300, + }); + + chart.data(data); + chart.scale('月均降雨量', { + nice: true, + }); + chart.tooltip({ + shared: true + }); + + chart + .interval() + .position('月份*月均降雨量'); + + chart.render(); + + const point = chart.getXY({ name: 'London', 月份: 'Jan.', 月均降雨量: 18.9 }); + // 相同的内容,先展示,再关闭,再展示,tooltip 应该展示 + chart.showTooltip(point); + chart.hideTooltip(); + + chart.showTooltip(point); + + const tooltip = chart.ele.getElementsByClassName('g2-tooltip')[0]; + // @ts-ignore + expect(tooltip.style.visibility).toBe('visible'); + + // 如果内容为空,tooltip 应该隐藏 + chart.showTooltip({ + x: point.x - 100, + y: point.y + }); + // @ts-ignore + expect(tooltip.style.visibility).toBe('hidden'); + }); +});