Skip to content

Commit

Permalink
fix: try to make test always success
Browse files Browse the repository at this point in the history
  • Loading branch information
visiky committed Mar 27, 2021
1 parent 4f4a75f commit e5136c1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion __tests__/unit/core/index-spec.ts
Expand Up @@ -201,7 +201,7 @@ describe('core', () => {
expect(line.triggerResize).toHaveBeenCalledTimes(0);

container.style.width = `${container.clientWidth + 10}px`;
await delay(200);
await delay(500);
// @ts-ignore
expect(line.triggerResize).toHaveBeenCalledTimes(1);

Expand Down
10 changes: 8 additions & 2 deletions __tests__/unit/plots/word-cloud/change-data-spec.ts
@@ -1,41 +1,47 @@
import { WordCloud } from '../../../../src';
import { CountryEconomy } from '../../../data/country-economy';
import { delay } from '../../../utils/delay';
import { createDiv } from '../../../utils/dom';

describe('word-cloud changeData', () => {
it('changeData: normal', () => {
it('changeData: normal', async () => {
const cloud = new WordCloud(createDiv(), {
width: 1024,
height: 1024,
data: CountryEconomy,
wordField: 'Country',
weightField: 'GDP',
animation: false,
});

cloud.render();

await delay(500);
expect(cloud.chart.geometries[0].elements.length).toEqual(CountryEconomy.length + 2);

const newData = CountryEconomy.slice(0, 20);
cloud.changeData(newData);
await delay(500);
expect(cloud.chart.geometries[0].elements.length).toEqual(newData.length + 2);
expect(cloud.options.data).toEqual(newData);

cloud.destroy();
});

it('changeData: from empty to have data', () => {
it('changeData: from empty to have data', async () => {
const cloud = new WordCloud(createDiv(), {
width: 1024,
height: 1024,
data: [],
wordField: 'Country',
weightField: 'GDP',
animation: false,
});

cloud.render();

cloud.changeData(CountryEconomy);
await delay(500);
expect(cloud.chart.geometries[0].elements.length).toEqual(CountryEconomy.length + 2);
expect(cloud.options.data).toEqual(CountryEconomy);

Expand Down

0 comments on commit e5136c1

Please sign in to comment.