Skip to content

Commit

Permalink
chore: 完善单测,去除only
Browse files Browse the repository at this point in the history
  • Loading branch information
lxfu1 committed Nov 21, 2020
1 parent ed623a2 commit 4a3b735
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions __tests__/unit/plots/heatmap/shape-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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',
Expand All @@ -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({
Expand All @@ -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();
Expand Down

0 comments on commit 4a3b735

Please sign in to comment.