Skip to content

Commit 0ee3348

Browse files
committed
Add test
1 parent 998bb1b commit 0ee3348

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
@@ -541,6 +541,35 @@ describe('<RadioButtonGroupInput />', () => {
541541
expect(screen.queryByRole('progressbar')).toBeNull();
542542
});
543543

544+
it('should render disabled choices marked as so', () => {
545+
const choices = [
546+
{ id: 1, name: 'VISA' },
547+
{ id: 2, name: 'Mastercard', disabled: true },
548+
];
549+
render(
550+
<AdminContext dataProvider={testDataProvider()}>
551+
<ResourceContextProvider value="creditcards">
552+
<SimpleForm onSubmit={jest.fn()}>
553+
<RadioButtonGroupInput
554+
{...defaultProps}
555+
choices={choices}
556+
/>
557+
</SimpleForm>
558+
</ResourceContextProvider>
559+
</AdminContext>
560+
);
561+
fireEvent.mouseDown(
562+
screen.getByLabelText('resources.creditcards.fields.type')
563+
);
564+
565+
expect(
566+
screen.getByText('VISA').getAttribute('aria-disabled')
567+
).toBeNull();
568+
expect(
569+
screen.getByText('Mastercard').getAttribute('aria-disabled')
570+
).toEqual('true');
571+
});
572+
544573
describe('inside ReferenceArrayInput', () => {
545574
it('should use the recordRepresentation as optionText', async () => {
546575
render(<InsideReferenceArrayInput />);

0 commit comments

Comments
 (0)