Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
arminmeh committed Jan 9, 2025
1 parent 112fb2c commit 679f628
Showing 1 changed file with 21 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ describeSkipIf(isJSDOM)('<DataGridPro /> - Data source lazy loader', () => {

apiRef.current.scrollToIndexes({ rowIndex: 9 });

// wait until the debounced fetch
await waitFor(() => {
expect(fetchRowsSpy.callCount).to.equal(2);
});

// wait until the rows are rendered
await waitFor(() => expect(getRow(10)).not.to.be.undefined);

Expand All @@ -237,6 +242,10 @@ describeSkipIf(isJSDOM)('<DataGridPro /> - Data source lazy loader', () => {

apiRef.current.sortColumn(mockServer.columns[0].field, 'asc');

await waitFor(() => {
expect(fetchRowsSpy.callCount).to.equal(3);
});

const afterSortingSearchParams = new URL(fetchRowsSpy.lastCall.args[0]).searchParams;
// last row is the end of the first page
expect(afterSortingSearchParams.get('end')).to.equal('9');
Expand All @@ -249,6 +258,11 @@ describeSkipIf(isJSDOM)('<DataGridPro /> - Data source lazy loader', () => {

apiRef.current.scrollToIndexes({ rowIndex: 9 });

// wait until the debounced fetch
await waitFor(() => {
expect(fetchRowsSpy.callCount).to.equal(2);
});

// wait until the rows are rendered
await waitFor(() => expect(getRow(10)).not.to.be.undefined);

Expand All @@ -266,6 +280,10 @@ describeSkipIf(isJSDOM)('<DataGridPro /> - Data source lazy loader', () => {
],
});

await waitFor(() => {
expect(fetchRowsSpy.callCount).to.equal(3);
});

const afterFilteringSearchParams = new URL(fetchRowsSpy.lastCall.args[0]).searchParams;
// last row is the end of the first page
expect(afterFilteringSearchParams.get('end')).to.equal('9');
Expand All @@ -287,7 +305,9 @@ describeSkipIf(isJSDOM)('<DataGridPro /> - Data source lazy loader', () => {
setProps({ rowCount: 100 });

// The 11th row should be a skeleton
expect(getRow(10).dataset.id).to.equal('auto-generated-skeleton-row-root-10');
await waitFor(() =>
expect(getRow(10).dataset.id).to.equal('auto-generated-skeleton-row-root-10'),
);
});

it('should reset the grid if the rowCount becomes unknown', async () => {
Expand Down

0 comments on commit 679f628

Please sign in to comment.