Skip to content

Commit 776c0ab

Browse files
committed
Add test
1 parent d2cd51e commit 776c0ab

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

packages/ra-ui-materialui/src/input/RadioButtonGroupInput.spec.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,35 @@ describe('<RadioButtonGroupInput />', () => {
569569
expect(disabledInput.disabled).toBe(true);
570570
});
571571

572+
it('should render disabled choices marked as so by disableValue prop', () => {
573+
const choices = [
574+
{ id: 1, name: 'VISA' },
575+
{ id: 2, name: 'Mastercard', not_available: true },
576+
];
577+
render(
578+
<AdminContext dataProvider={testDataProvider()}>
579+
<ResourceContextProvider value="creditcards">
580+
<SimpleForm onSubmit={jest.fn()}>
581+
<RadioButtonGroupInput
582+
{...defaultProps}
583+
choices={choices}
584+
disableValue="not_available"
585+
/>
586+
</SimpleForm>
587+
</ResourceContextProvider>
588+
</AdminContext>
589+
);
590+
fireEvent.mouseDown(screen.getByLabelText('Mastercard'));
591+
592+
const enabledInput = screen.getByLabelText('VISA') as HTMLInputElement;
593+
expect(enabledInput.disabled).toBe(false);
594+
595+
const disabledInput = screen.getByLabelText(
596+
'Mastercard'
597+
) as HTMLInputElement;
598+
expect(disabledInput.disabled).toBe(true);
599+
});
600+
572601
describe('inside ReferenceArrayInput', () => {
573602
it('should use the recordRepresentation as optionText', async () => {
574603
render(<InsideReferenceArrayInput />);

0 commit comments

Comments
 (0)