test: Fix act error in ExportToCVSDropdown test (#21401)
This commit is contained in:
parent
9318e269b1
commit
6fad3f9a35
|
|
@ -18,21 +18,27 @@
|
|||
*/
|
||||
import React from 'react';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { render, screen } from 'spec/helpers/testing-library';
|
||||
import { render, screen, waitFor } from 'spec/helpers/testing-library';
|
||||
import { ExportToCSVDropdown } from './index';
|
||||
|
||||
const exportCSVOriginal = jest.fn();
|
||||
const exportCSVPivoted = jest.fn();
|
||||
|
||||
test('Dropdown button with menu renders', () => {
|
||||
render(
|
||||
<ExportToCSVDropdown
|
||||
exportCSVOriginal={exportCSVOriginal}
|
||||
exportCSVPivoted={exportCSVPivoted}
|
||||
>
|
||||
<div>.CSV</div>
|
||||
</ExportToCSVDropdown>,
|
||||
const waitForRender = () => {
|
||||
waitFor(() =>
|
||||
render(
|
||||
<ExportToCSVDropdown
|
||||
exportCSVOriginal={exportCSVOriginal}
|
||||
exportCSVPivoted={exportCSVPivoted}
|
||||
>
|
||||
<div>.CSV</div>
|
||||
</ExportToCSVDropdown>,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
test('Dropdown button with menu renders', () => {
|
||||
waitForRender();
|
||||
|
||||
expect(screen.getByText('.CSV')).toBeVisible();
|
||||
|
||||
|
|
@ -43,14 +49,7 @@ test('Dropdown button with menu renders', () => {
|
|||
});
|
||||
|
||||
test('Call export csv original on click', () => {
|
||||
render(
|
||||
<ExportToCSVDropdown
|
||||
exportCSVOriginal={exportCSVOriginal}
|
||||
exportCSVPivoted={exportCSVPivoted}
|
||||
>
|
||||
<div>.CSV</div>
|
||||
</ExportToCSVDropdown>,
|
||||
);
|
||||
waitForRender();
|
||||
|
||||
userEvent.click(screen.getByText('.CSV'));
|
||||
userEvent.click(screen.getByText('Original'));
|
||||
|
|
@ -59,14 +58,7 @@ test('Call export csv original on click', () => {
|
|||
});
|
||||
|
||||
test('Call export csv pivoted on click', () => {
|
||||
render(
|
||||
<ExportToCSVDropdown
|
||||
exportCSVOriginal={exportCSVOriginal}
|
||||
exportCSVPivoted={exportCSVPivoted}
|
||||
>
|
||||
<div>.CSV</div>
|
||||
</ExportToCSVDropdown>,
|
||||
);
|
||||
waitForRender();
|
||||
|
||||
userEvent.click(screen.getByText('.CSV'));
|
||||
userEvent.click(screen.getByText('Pivoted'));
|
||||
|
|
|
|||
Loading…
Reference in New Issue