diff --git a/packages/ra-ui-materialui/src/field/ArrayField.spec.tsx b/packages/ra-ui-materialui/src/field/ArrayField.spec.tsx
index 98258779526..d82345d2ad2 100644
--- a/packages/ra-ui-materialui/src/field/ArrayField.spec.tsx
+++ b/packages/ra-ui-materialui/src/field/ArrayField.spec.tsx
@@ -6,6 +6,7 @@ import ArrayField from './ArrayField';
import NumberField from './NumberField';
import TextField from './TextField';
import Datagrid from '../list/datagrid/Datagrid';
+import SimpleList from '../list/SimpleList';
describe('', () => {
const currentSort = { field: 'id', order: 'ASC' };
@@ -27,7 +28,27 @@ describe('', () => {
);
});
- it('should render the underlying iterator component', () => {
+ it('should render the alternative empty component', () => {
+ const { queryByText } = render(
+
+
+ No posts}>
+
+
+
+
+ );
+ expect(queryByText('No posts')).not.toBeNull();
+ });
+
+ it('should render the iterator component', () => {
const { queryByText } = render(
', () => {
expect(queryByText('456')).not.toBeNull();
});
- it('should render the alternative empty component', () => {
+ it('should render the iterator component', () => {
const { queryByText } = render(
', () => {
resource="posts"
record={{
id: 123,
- arr: [],
+ arr: [
+ { id: 123, foo: 'bar' },
+ { id: 456, foo: 'baz' },
+ ],
}}
>
- No posts}>
-
-
+ record.foo}
+ secondaryText={record => record.id}
+ />
);
- expect(queryByText('No posts')).not.toBeNull();
+
+ // Test the fields values
+ expect(queryByText('bar')).not.toBeNull();
+ expect(queryByText('123')).not.toBeNull();
+
+ expect(queryByText('baz')).not.toBeNull();
+ expect(queryByText('456')).not.toBeNull();
});
});
diff --git a/packages/ra-ui-materialui/src/field/ArrayField.tsx b/packages/ra-ui-materialui/src/field/ArrayField.tsx
index c25131b1c53..bf44224231f 100644
--- a/packages/ra-ui-materialui/src/field/ArrayField.tsx
+++ b/packages/ra-ui-materialui/src/field/ArrayField.tsx
@@ -165,7 +165,7 @@ export const ArrayField: FC = memo(props => {
setPerPage: null,
setSort: null,
showFilter: null,
- total: null,
+ total: ids.length,
}}
>
{cloneElement(Children.only(children), {