Skip to content

Commit

Permalink
Fix(WrapperField): source props should not be required
Browse files Browse the repository at this point in the history
  • Loading branch information
arnault-dev committed Jul 9, 2024
1 parent 1e89fa7 commit 2c1dbf9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions packages/ra-ui-materialui/src/field/WrapperField.spec.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { render } from '@testing-library/react';
import expect from 'expect';
import * as React from 'react';

import { UrlField } from './UrlField';
import { WrapperField } from './WrapperField';

const url = 'https://en.wikipedia.org/wiki/HAL_9000';

describe('<WrapperField />', () => {
it('should render its children', () => {
const record = { id: 123, website: url };
const { getByText } = render(
<WrapperField label="wrapper">
<UrlField record={record} source="website" />
</WrapperField>
);
const link = getByText(url) as HTMLAnchorElement;
expect(link.tagName).toEqual('A');
expect(link.href).toEqual(url);
});
});
3 changes: 2 additions & 1 deletion packages/ra-ui-materialui/src/field/WrapperField.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WrapperField.displayName = 'WrapperField';

export interface WrapperFieldProps<
RecordType extends Record<string, any> = Record<string, any>,
> extends FieldProps<RecordType> {
> extends Omit<FieldProps<RecordType>, 'source'> {
source?: FieldProps<RecordType>['source'];
children: ReactNode;
}

0 comments on commit 2c1dbf9

Please sign in to comment.