Skip to content

Commit ed682f2

Browse files
authored
fix: 尝试修复词云图单测 (#2471)
1 parent c9d79f1 commit ed682f2

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

__tests__/unit/plots/word-cloud/change-data-spec.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import { WordCloud } from '../../../../src';
22
import { CountryEconomy } from '../../../data/country-economy';
33
import { createDiv } from '../../../utils/dom';
4+
import { delay } from '../../../utils/delay';
45

56
describe('word-cloud changeData', () => {
6-
it('changeData: normal', () => {
7+
it('changeData: normal', async () => {
78
const cloud = new WordCloud(createDiv(), {
89
width: 1024,
910
height: 1024,
@@ -18,6 +19,8 @@ describe('word-cloud changeData', () => {
1819

1920
cloud.render();
2021

22+
await delay(cloud.options.timeInterval || 10);
23+
2124
expect(cloud.chart.geometries[0].elements.length).toEqual(CountryEconomy.length + 2);
2225

2326
const newData = CountryEconomy.slice(0, 20);
@@ -28,7 +31,7 @@ describe('word-cloud changeData', () => {
2831
cloud.destroy();
2932
});
3033

31-
it('changeData: from empty to have data', () => {
34+
it('changeData: from empty to have data', async () => {
3235
const cloud = new WordCloud(createDiv(), {
3336
width: 1024,
3437
height: 1024,
@@ -44,6 +47,9 @@ describe('word-cloud changeData', () => {
4447
cloud.render();
4548

4649
cloud.changeData(CountryEconomy);
50+
51+
await delay(cloud.options.timeInterval || 10);
52+
4753
expect(cloud.chart.geometries[0].elements.length).toEqual(CountryEconomy.length + 2);
4854
expect(cloud.options.data).toEqual(CountryEconomy);
4955

__tests__/unit/plots/word-cloud/legend-spec.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { groupBy, keys } from '@antv/util';
22
import { WordCloud } from '../../../../src';
33
import { CountryEconomy } from '../../../data/country-economy';
44
import { createDiv } from '../../../utils/dom';
5+
import { delay } from '../../../utils/delay';
56

67
describe('word-cloud', () => {
78
it('legend', () => {
@@ -24,7 +25,7 @@ describe('word-cloud', () => {
2425
cloud.destroy();
2526
});
2627

27-
it('开启 legend', () => {
28+
it('开启 legend', async () => {
2829
const cloud = new WordCloud(createDiv('x*y'), {
2930
width: 400,
3031
height: 300,
@@ -43,6 +44,7 @@ describe('word-cloud', () => {
4344
cloud.render();
4445

4546
const options = cloud.chart.getOptions();
47+
await delay(cloud.options.timeInterval || 10);
4648

4749
expect(options.legends).not.toBe(false);
4850
const legendController = cloud.chart.getController('legend');

0 commit comments

Comments
 (0)