|
1 | 1 | import React from 'react';
|
2 |
| -import { assert } from 'chai'; |
| 2 | +import { assert, expect } from 'chai'; |
3 | 3 | import { getClasses, createMount } from '@material-ui/core/test-utils';
|
4 | 4 | import describeConformance from '@material-ui/core/test-utils/describeConformance';
|
| 5 | +import { createClientRender } from 'test/utils/createClientRender'; |
| 6 | +import FormControl from '../FormControl'; |
5 | 7 | import Radio from './Radio';
|
6 | 8 | import IconButton from '../IconButton';
|
7 | 9 |
|
8 | 10 | describe('<Radio />', () => {
|
| 11 | + const render = createClientRender(); |
9 | 12 | let classes;
|
10 | 13 | let mount;
|
11 | 14 |
|
@@ -47,4 +50,50 @@ describe('<Radio />', () => {
|
47 | 50 | assert.strictEqual(wrapper.find('svg[data-mui-test="RadioButtonCheckedIcon"]').length, 1);
|
48 | 51 | });
|
49 | 52 | });
|
| 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 | + }); |
50 | 99 | });
|
0 commit comments