From 4a3b735dac658a77ae34b7fb4dd51d745cd9f847 Mon Sep 17 00:00:00 2001 From: lxfu1 <954055752@qq.com> Date: Sat, 21 Nov 2020 14:45:15 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E5=AE=8C=E5=96=84=E5=8D=95=E6=B5=8B,?= =?UTF-8?q?=E5=8E=BB=E9=99=A4only?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- __tests__/unit/plots/heatmap/shape-spec.ts | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/__tests__/unit/plots/heatmap/shape-spec.ts b/__tests__/unit/plots/heatmap/shape-spec.ts index 72248d0aaf..8218881a8e 100644 --- a/__tests__/unit/plots/heatmap/shape-spec.ts +++ b/__tests__/unit/plots/heatmap/shape-spec.ts @@ -122,11 +122,16 @@ describe('heatmap', () => { // default fill expect(elements[0].getModel().color).toBeUndefined(); expect(elements[0].getModel().defaultStyle.fill).toBe('#5B8FF9'); + expect(elements[0].shape.attr('fill')).toBe('#5B8FF9'); expect(heatmap.chart.geometries[0].labelOption).toBeUndefined(); heatmap.update({ colorField: 'sales', }); expect(heatmap.chart.geometries[0].elements[0].getModel().color).toBeDefined(); + const currentElements = heatmap.chart.geometries[0].elements; + const firstColor = currentElements[0].shape.attr('fill'); + const lastColor = currentElements[currentElements.length - 1].shape.attr('fill'); + expect(firstColor !== lastColor).toBeTruthy(); // @ts-ignore expect(heatmap.chart.geometries[0].labelOption.fields).toEqual(['sales']); heatmap.update({ @@ -135,15 +140,18 @@ describe('heatmap', () => { }, }); expect(heatmap.chart.geometries[0].elements[0].getModel().style.fill).toBe('red'); + const updateElements = heatmap.chart.geometries[0].elements; + expect(updateElements[0].shape.attr('fill')).toBe('red'); + expect(updateElements[updateElements.length - 1].shape.attr('fill')).toBe('red'); // @ts-ignore expect(heatmap.chart.geometries[0].styleOption.cfg.fill).toBe('red'); heatmap.destroy(); }); - it.only('x*y*color and shape*square', () => { + it('x*y*color and shape*square', () => { const heatmap = new Heatmap(createDiv('shape*fill'), { width: 400, height: 300, - data: semanticBasicHeatmapData, + data: semanticBasicHeatmapData.sort((p, n) => p.sales - n.sales), xField: 'name', yField: 'day', shape: 'square', @@ -165,12 +173,17 @@ describe('heatmap', () => { // default fill expect(elements[0].getModel().color).toBeUndefined(); expect(elements[0].getModel().defaultStyle.fill).toBe('#5B8FF9'); + expect(elements[0].shape.attr('fill')).toBe('#5B8FF9'); expect(heatmap.chart.geometries[0].labelOption).toBeUndefined(); heatmap.update({ colorField: 'sales', }); expect(heatmap.chart.geometries[0].elements[0].getModel().color).toBeDefined(); + const currentElements = heatmap.chart.geometries[0].elements; + const firstColor = currentElements[0].shape.attr('fill'); + const lastColor = currentElements[currentElements.length - 1].shape.attr('fill'); + expect(firstColor !== lastColor).toBeTruthy(); // @ts-ignore expect(heatmap.chart.geometries[0].labelOption.fields).toEqual(['sales']); heatmap.update({ @@ -179,6 +192,9 @@ describe('heatmap', () => { }, }); expect(heatmap.chart.geometries[0].elements[0].getModel().style.fill).toBe('red'); + const updateElements = heatmap.chart.geometries[0].elements; + expect(updateElements[0].shape.attr('fill')).toBe('red'); + expect(updateElements[updateElements.length - 1].shape.attr('fill')).toBe('red'); // @ts-ignore expect(heatmap.chart.geometries[0].styleOption.cfg.fill).toBe('red'); heatmap.destroy();