Skip to content

Commit 4ce5679

Browse files
committed
update show test to display the datagrid
1 parent d4118e7 commit 4ce5679

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/ra-ui-materialui/src/detail/ShowGuesser.spec.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,26 @@ import { ThemeProvider } from '../theme/ThemeProvider';
88

99
describe('<ShowGuesser />', () => {
1010
it('should log the guessed Show view based on the fetched record', async () => {
11-
const logSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
11+
const logSpy = jest
12+
.spyOn(console, 'log')
13+
.mockImplementation(console.warn);
1214
const dataProvider = {
1315
getOne: () =>
1416
Promise.resolve({
1517
data: {
1618
id: 123,
17-
author: 'john doe',
19+
authors: [
20+
{ id: 1, name: 'john doe', dob: '1990-01-01' },
21+
{ id: 2, name: 'jane doe', dob: '1992-01-01' },
22+
],
1823
post_id: 6,
1924
score: 3,
2025
body: "Queen, tossing her head through the wood. 'If it had lost something; and she felt sure it.",
2126
created_at: new Date('2012-08-02'),
2227
tags_ids: [1, 2],
2328
},
2429
}),
30+
getMany: () => Promise.resolve({ data: [] }),
2531
};
2632
render(
2733
<ThemeProvider>
@@ -35,13 +41,15 @@ describe('<ShowGuesser />', () => {
3541
});
3642
expect(logSpy).toHaveBeenCalledWith(`Guessed Show:
3743
38-
import { DateField, NumberField, ReferenceArrayField, ReferenceField, Show, SimpleShowLayout, TextField } from 'react-admin';
44+
import { ArrayField, Datagrid, DateField, NumberField, ReferenceArrayField, ReferenceField, Show, SimpleShowLayout, TextField } from 'react-admin';
3945
4046
export const CommentShow = () => (
4147
<Show>
4248
<SimpleShowLayout>
4349
<TextField source="id" />
44-
<TextField source="author" />
50+
<ArrayField source="authors"><Datagrid><TextField source="id" />
51+
<TextField source="name" />
52+
<DateField source="dob" /></Datagrid></ArrayField>
4553
<ReferenceField source="post_id" reference="posts" />
4654
<NumberField source="score" />
4755
<TextField source="body" />

0 commit comments

Comments
 (0)