From 3dca3e1e7dc846bc8864804a97dad2fb89a78d15 Mon Sep 17 00:00:00 2001 From: Armin Mehinovic <4390250+arminmeh@users.noreply.github.com> Date: Thu, 13 Feb 2025 13:32:09 +0100 Subject: [PATCH] [test] Fix DataGrid data source error test on React 18 (#16565) --- .../src/tests/dataSource.DataGridPro.test.tsx | 30 ++++++++----------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/packages/x-data-grid-pro/src/tests/dataSource.DataGridPro.test.tsx b/packages/x-data-grid-pro/src/tests/dataSource.DataGridPro.test.tsx index ba0d21fcd5668..6f6622cbead11 100644 --- a/packages/x-data-grid-pro/src/tests/dataSource.DataGridPro.test.tsx +++ b/packages/x-data-grid-pro/src/tests/dataSource.DataGridPro.test.tsx @@ -277,26 +277,22 @@ describeSkipIf(isJSDOM)(' - Data source', () => { describe('Error handling', () => { it('should call `unstable_onDataSourceError` when the data source returns an error', async () => { - const onDataSourceError = spy(); - - const dataSource: GridDataSource = { - getRows: () => { - throw new Error('Could not fetch the data'); - }, - }; - - render( -
- -
, + const onDataSourceErrorSpy = spy(); + const { setProps } = render( + , ); + expect(onDataSourceErrorSpy.callCount).to.equal(0); + + setProps({ shouldRequestsFail: true }); + act(() => { + apiRef.current.unstable_dataSource.fetchRows(); + }); await waitFor(() => { - expect(onDataSourceError.callCount).to.equal(1); + expect(onDataSourceErrorSpy.callCount).to.equal(1); }); }); });