Skip to content

Commit 2f3a5ab

Browse files
committed
[test] fix tests related to timings
1 parent 2877c95 commit 2f3a5ab

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/ui/public/visualize/components/visualization_chart.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919

2020
jest.useFakeTimers();
2121

22+
import { promisify } from 'util';
2223
import React from 'react';
2324
import { render, mount } from 'enzyme';
2425
import { VisualizationChart } from './visualization_chart';
2526

2627
let renderPromise;
2728

29+
const nextTick = promisify(process.nextTick);
30+
2831
class VisualizationStub {
2932
constructor(el, vis) {
3033
this.el = el;
@@ -70,6 +73,7 @@ describe('<VisualizationChart/>', () => {
7073

7174
jest.runAllTimers();
7275
await renderPromise;
76+
await nextTick();
7377
expect(renderStart).toHaveBeenCalledTimes(1);
7478
expect(renderComplete).toHaveBeenCalledTimes(1);
7579

@@ -89,12 +93,14 @@ describe('<VisualizationChart/>', () => {
8993
domNode.addEventListener('renderComplete', renderComplete);
9094
jest.runAllTimers();
9195
await renderPromise;
96+
await nextTick();
9297
expect(renderComplete).toHaveBeenCalledTimes(1);
9398

9499
vis.params.markdown = 'new text';
95100
wrapper.setProps({ vis });
96101
jest.runAllTimers();
97102
await renderPromise;
103+
await nextTick();
98104

99105
expect(wrapper.find('.visChart').text()).toBe('new text');
100106
expect(renderComplete).toHaveBeenCalledTimes(2);

0 commit comments

Comments
 (0)