Skip to content

Commit e8643d2

Browse files
authored
chore: 完善单测,去除only (#1984)
1 parent c460fe9 commit e8643d2

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

__tests__/unit/plots/heatmap/shape-spec.ts

+18-2
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,16 @@ describe('heatmap', () => {
122122
// default fill
123123
expect(elements[0].getModel().color).toBeUndefined();
124124
expect(elements[0].getModel().defaultStyle.fill).toBe('#5B8FF9');
125+
expect(elements[0].shape.attr('fill')).toBe('#5B8FF9');
125126
expect(heatmap.chart.geometries[0].labelOption).toBeUndefined();
126127
heatmap.update({
127128
colorField: 'sales',
128129
});
129130
expect(heatmap.chart.geometries[0].elements[0].getModel().color).toBeDefined();
131+
const currentElements = heatmap.chart.geometries[0].elements;
132+
const firstColor = currentElements[0].shape.attr('fill');
133+
const lastColor = currentElements[currentElements.length - 1].shape.attr('fill');
134+
expect(firstColor !== lastColor).toBeTruthy();
130135
// @ts-ignore
131136
expect(heatmap.chart.geometries[0].labelOption.fields).toEqual(['sales']);
132137
heatmap.update({
@@ -135,15 +140,18 @@ describe('heatmap', () => {
135140
},
136141
});
137142
expect(heatmap.chart.geometries[0].elements[0].getModel().style.fill).toBe('red');
143+
const updateElements = heatmap.chart.geometries[0].elements;
144+
expect(updateElements[0].shape.attr('fill')).toBe('red');
145+
expect(updateElements[updateElements.length - 1].shape.attr('fill')).toBe('red');
138146
// @ts-ignore
139147
expect(heatmap.chart.geometries[0].styleOption.cfg.fill).toBe('red');
140148
heatmap.destroy();
141149
});
142-
it.only('x*y*color and shape*square', () => {
150+
it('x*y*color and shape*square', () => {
143151
const heatmap = new Heatmap(createDiv('shape*fill'), {
144152
width: 400,
145153
height: 300,
146-
data: semanticBasicHeatmapData,
154+
data: semanticBasicHeatmapData.sort((p, n) => p.sales - n.sales),
147155
xField: 'name',
148156
yField: 'day',
149157
shape: 'square',
@@ -165,12 +173,17 @@ describe('heatmap', () => {
165173
// default fill
166174
expect(elements[0].getModel().color).toBeUndefined();
167175
expect(elements[0].getModel().defaultStyle.fill).toBe('#5B8FF9');
176+
expect(elements[0].shape.attr('fill')).toBe('#5B8FF9');
168177
expect(heatmap.chart.geometries[0].labelOption).toBeUndefined();
169178

170179
heatmap.update({
171180
colorField: 'sales',
172181
});
173182
expect(heatmap.chart.geometries[0].elements[0].getModel().color).toBeDefined();
183+
const currentElements = heatmap.chart.geometries[0].elements;
184+
const firstColor = currentElements[0].shape.attr('fill');
185+
const lastColor = currentElements[currentElements.length - 1].shape.attr('fill');
186+
expect(firstColor !== lastColor).toBeTruthy();
174187
// @ts-ignore
175188
expect(heatmap.chart.geometries[0].labelOption.fields).toEqual(['sales']);
176189
heatmap.update({
@@ -179,6 +192,9 @@ describe('heatmap', () => {
179192
},
180193
});
181194
expect(heatmap.chart.geometries[0].elements[0].getModel().style.fill).toBe('red');
195+
const updateElements = heatmap.chart.geometries[0].elements;
196+
expect(updateElements[0].shape.attr('fill')).toBe('red');
197+
expect(updateElements[updateElements.length - 1].shape.attr('fill')).toBe('red');
182198
// @ts-ignore
183199
expect(heatmap.chart.geometries[0].styleOption.cfg.fill).toBe('red');
184200
heatmap.destroy();

0 commit comments

Comments
 (0)