Skip to content

Commit 467446f

Browse files
committed
Add a test for default params handling
1 parent 59a4bd2 commit 467446f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

packages/ra-core/src/controller/list/useListParams.spec.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,36 @@ describe('useListParams', () => {
684684
});
685685
});
686686

687+
it('should not synchronize location with store if the store parameters are the defaults', async () => {
688+
let location;
689+
render(
690+
<TestMemoryRouter
691+
locationCallback={l => {
692+
location = l;
693+
}}
694+
>
695+
<CoreAdminContext dataProvider={testDataProvider()}>
696+
<Component disableSyncWithLocation />
697+
</CoreAdminContext>
698+
</TestMemoryRouter>
699+
);
700+
701+
// Let React do its thing
702+
await new Promise(resolve => setTimeout(resolve, 0));
703+
704+
await waitFor(() => {
705+
expect(location).toEqual(
706+
expect.objectContaining({
707+
hash: '',
708+
key: expect.any(String),
709+
state: null,
710+
pathname: '/',
711+
search: '',
712+
})
713+
);
714+
});
715+
});
716+
687717
it('should not synchronize location with store when sync is not enabled', async () => {
688718
let location;
689719
let storeValue;

0 commit comments

Comments
 (0)