Skip to content

Commit 8652b8e

Browse files
committed
[Radio] Test disabled state with FormControl
1 parent 3b176f0 commit 8652b8e

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

packages/material-ui/src/Radio/Radio.test.js

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import React from 'react';
2-
import { assert } from 'chai';
2+
import { assert, expect } from 'chai';
33
import { getClasses, createMount } from '@material-ui/core/test-utils';
44
import describeConformance from '@material-ui/core/test-utils/describeConformance';
5+
import { createClientRender } from 'test/utils/createClientRender';
6+
import FormControl from '../FormControl';
57
import Radio from './Radio';
68
import IconButton from '../IconButton';
79

810
describe('<Radio />', () => {
11+
const render = createClientRender();
912
let classes;
1013
let mount;
1114

@@ -47,4 +50,50 @@ describe('<Radio />', () => {
4750
assert.strictEqual(wrapper.find('svg[data-mui-test="RadioButtonCheckedIcon"]').length, 1);
4851
});
4952
});
53+
54+
describe('with FormControl', () => {
55+
describe('enabled', () => {
56+
it('should not have the disabled class', () => {
57+
const { getByTestId } = render(
58+
<FormControl>
59+
<Radio data-testid="root" />
60+
</FormControl>,
61+
);
62+
63+
expect(getByTestId('root')).not.to.have.class(classes.disabled);
64+
});
65+
66+
it('should be overridden by props', () => {
67+
const { getByTestId } = render(
68+
<FormControl>
69+
<Radio data-testid="root" disabled />
70+
</FormControl>,
71+
);
72+
73+
expect(getByTestId('root')).to.have.class(classes.disabled);
74+
});
75+
});
76+
77+
describe('disabled', () => {
78+
it('should have the disabled class', () => {
79+
const { getByTestId } = render(
80+
<FormControl disabled>
81+
<Radio data-testid="root" />
82+
</FormControl>,
83+
);
84+
85+
expect(getByTestId('root')).to.have.class(classes.disabled);
86+
});
87+
88+
it('should be overridden by props', () => {
89+
const { getByTestId } = render(
90+
<FormControl disabled>
91+
<Radio data-testid="root" disabled={false} />
92+
</FormControl>,
93+
);
94+
95+
expect(getByTestId('root')).not.to.have.class(classes.disabled);
96+
});
97+
});
98+
});
5099
});

0 commit comments

Comments
 (0)