Skip to content

Commit

Permalink
[test] Replace waitFor with act
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Oct 6, 2024
1 parent 2c86040 commit 64e41d0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('<DataGridPro /> - Pagination', () => {
act(() => {
apiRef.current.setPage(1);
});

expect(getColumnValues(0)).to.deep.equal(['1']);
});

Expand Down Expand Up @@ -65,7 +64,6 @@ describe('<DataGridPro /> - Pagination', () => {
act(() => {
apiRef.current.setPage(50);
});

expect(getColumnValues(0)).to.deep.equal(['19']);
});
});
Expand Down
4 changes: 3 additions & 1 deletion packages/x-data-grid-pro/src/tests/rows.DataGridPro.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,9 @@ describe('<DataGridPro /> - Rows', () => {
/>,
);
expect(document.querySelectorAll('[role="row"][data-rowindex]')).to.have.length(6);
act(() => apiRef.current.setPage(1));
act(() => {
apiRef.current.setPage(1);
});
expect(document.querySelectorAll('[role="row"][data-rowindex]')).to.have.length(4);
});
});
Expand Down
10 changes: 5 additions & 5 deletions packages/x-data-grid/src/tests/rowSpanning.DataGrid.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { createRenderer, waitFor, fireEvent, act } from '@mui/internal-test-utils';
import { createRenderer, fireEvent, act } from '@mui/internal-test-utils';
import { expect } from 'chai';
import { DataGrid, useGridApiRef, DataGridProps, GridApi } from '@mui/x-data-grid';
import { getCell, getActiveCell } from 'test/utils/helperFn';
Expand Down Expand Up @@ -224,10 +224,10 @@ describe('<DataGrid /> - Row spanning', () => {
/>,
);
expect(Object.keys(apiRef.current.state.rowSpanning.spannedCells).length).to.equal(0);
apiRef.current.setPage(1);
await waitFor(() =>
expect(Object.keys(apiRef.current.state.rowSpanning.spannedCells).length).to.equal(1),
);
await act(() => {
apiRef.current.setPage(1);
});
expect(Object.keys(apiRef.current.state.rowSpanning.spannedCells).length).to.equal(1);
expect(Object.keys(apiRef.current.state.rowSpanning.hiddenCells).length).to.equal(1);
});
});
Expand Down

0 comments on commit 64e41d0

Please sign in to comment.