From 98fe13b40a7635a106f44b141ed11fb84c5a7ae9 Mon Sep 17 00:00:00 2001 From: fzaninotto Date: Mon, 10 Jun 2024 15:02:15 +0200 Subject: [PATCH] Fix combineDataProvider throws a runtime error Closes #9909 --- .../src/dataProvider/combineDataProviders.spec.ts | 9 +++++++-- .../ra-core/src/dataProvider/combineDataProviders.ts | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/packages/ra-core/src/dataProvider/combineDataProviders.spec.ts b/packages/ra-core/src/dataProvider/combineDataProviders.spec.ts index f16157722d1..e6667ab2585 100644 --- a/packages/ra-core/src/dataProvider/combineDataProviders.spec.ts +++ b/packages/ra-core/src/dataProvider/combineDataProviders.spec.ts @@ -1,3 +1,4 @@ +import expect from 'expect'; import { testDataProvider } from './testDataProvider'; import { combineDataProviders } from './combineDataProviders'; @@ -25,7 +26,9 @@ describe('combineDataProviders', () => { }); await dataProvider.getOne('comments', { id: 1 }); expect(dataProvider1.getOne).not.toHaveBeenCalled(); - expect(dataProvider2.getOne).toHaveBeenCalled(); + expect(dataProvider2.getOne).toHaveBeenCalledWith('comments', { + id: 1, + }); }); it('works with a dataProvider that returns a promise', async () => { const dataProvider1 = testDataProvider({ @@ -51,6 +54,8 @@ describe('combineDataProviders', () => { const dataProvider = await dataProviderValue; await dataProvider.getOne('comments', { id: 1 }); expect(dataProvider1.getOne).not.toHaveBeenCalled(); - expect(dataProvider2.getOne).toHaveBeenCalled(); + expect(dataProvider2.getOne).toHaveBeenCalledWith('comments', { + id: 1, + }); }); }); diff --git a/packages/ra-core/src/dataProvider/combineDataProviders.ts b/packages/ra-core/src/dataProvider/combineDataProviders.ts index b65b61e3a90..b9ac5988f95 100644 --- a/packages/ra-core/src/dataProvider/combineDataProviders.ts +++ b/packages/ra-core/src/dataProvider/combineDataProviders.ts @@ -29,7 +29,7 @@ export const combineDataProviders = ( if (name === 'then') { return null; } - return (resource, params) => { + return (resource, ...params) => { if (typeof name === 'symbol') { return; }