Skip to content

Commit 0c017e9

Browse files
committed
fix tests
1 parent f4900c2 commit 0c017e9

File tree

2 files changed

+46
-42
lines changed

2 files changed

+46
-42
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,7 @@ describe('useInfiniteListController', () => {
701701
);
702702
await screen.findByText('A post - 0 votes');
703703
expect(dataProvider.getList).toHaveBeenCalled();
704-
// Only called once by NavigationToFirstResource
705-
expect(authProvider.checkAuth).toHaveBeenCalledTimes(1);
704+
expect(authProvider.checkAuth).not.toHaveBeenCalled();
706705
});
707706

708707
it('should not call checkAuth nor canAccess when disableAuthentication is true', async () => {

packages/ra-core/src/controller/list/useListController.stories.tsx

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ListController } from './ListController';
77
import type { DataProvider } from '../../types';
88
import type { ListControllerResult } from './useListController';
99
import { useNotificationContext } from '../../notification';
10+
import { TestMemoryRouter } from '../..';
1011

1112
export default {
1213
title: 'ra-core/controller/list/useListController',
@@ -95,9 +96,11 @@ export const Basic = ({
9596
dataProvider?: DataProvider;
9697
children?: (params: ListControllerResult) => React.ReactNode;
9798
}) => (
98-
<CoreAdminContext dataProvider={dataProvider}>
99-
<ListController resource="posts">{children}</ListController>
100-
</CoreAdminContext>
99+
<TestMemoryRouter>
100+
<CoreAdminContext dataProvider={dataProvider}>
101+
<ListController resource="posts">{children}</ListController>
102+
</CoreAdminContext>
103+
</TestMemoryRouter>
101104
);
102105

103106
const OnlineManager = () => {
@@ -147,42 +150,44 @@ const Notifications = () => {
147150
};
148151

149152
export const Offline = () => (
150-
<CoreAdminContext dataProvider={defaultDataProvider}>
151-
<OnlineManager />
152-
<ListController resource="posts" perPage={3}>
153-
{params => (
154-
<div>
155-
<div
156-
style={{
157-
display: 'flex',
158-
alignItems: 'center',
159-
gap: '10px',
160-
}}
161-
>
162-
<button onClick={() => params.setPage(1)}>
163-
Page 1
164-
</button>
165-
<button onClick={() => params.setPage(2)}>
166-
Page 2
167-
</button>
168-
<button onClick={() => params.setPage(3)}>
169-
Page 3
170-
</button>
153+
<TestMemoryRouter>
154+
<CoreAdminContext dataProvider={defaultDataProvider}>
155+
<OnlineManager />
156+
<ListController resource="posts" perPage={3}>
157+
{params => (
158+
<div>
159+
<div
160+
style={{
161+
display: 'flex',
162+
alignItems: 'center',
163+
gap: '10px',
164+
}}
165+
>
166+
<button onClick={() => params.setPage(1)}>
167+
Page 1
168+
</button>
169+
<button onClick={() => params.setPage(2)}>
170+
Page 2
171+
</button>
172+
<button onClick={() => params.setPage(3)}>
173+
Page 3
174+
</button>
175+
</div>
176+
<ul
177+
style={{
178+
listStyleType: 'none',
179+
}}
180+
>
181+
{params.data?.map(record => (
182+
<li key={record.id}>
183+
{record.id} - {record.title}
184+
</li>
185+
))}
186+
</ul>
171187
</div>
172-
<ul
173-
style={{
174-
listStyleType: 'none',
175-
}}
176-
>
177-
{params.data?.map(record => (
178-
<li key={record.id}>
179-
{record.id} - {record.title}
180-
</li>
181-
))}
182-
</ul>
183-
</div>
184-
)}
185-
</ListController>
186-
<Notifications />
187-
</CoreAdminContext>
188+
)}
189+
</ListController>
190+
<Notifications />
191+
</CoreAdminContext>
192+
</TestMemoryRouter>
188193
);

0 commit comments

Comments
 (0)