Skip to content

Commit

Permalink
[Radio] Test disabled state with FormControl
Browse files Browse the repository at this point in the history
  • Loading branch information
rostislavbobo committed Jan 21, 2020
1 parent 3b176f0 commit 8652b8e
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion packages/material-ui/src/Radio/Radio.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import React from 'react';
import { assert } from 'chai';
import { assert, expect } from 'chai';
import { getClasses, createMount } from '@material-ui/core/test-utils';
import describeConformance from '@material-ui/core/test-utils/describeConformance';
import { createClientRender } from 'test/utils/createClientRender';
import FormControl from '../FormControl';
import Radio from './Radio';
import IconButton from '../IconButton';

describe('<Radio />', () => {
const render = createClientRender();
let classes;
let mount;

Expand Down Expand Up @@ -47,4 +50,50 @@ describe('<Radio />', () => {
assert.strictEqual(wrapper.find('svg[data-mui-test="RadioButtonCheckedIcon"]').length, 1);
});
});

describe('with FormControl', () => {
describe('enabled', () => {
it('should not have the disabled class', () => {
const { getByTestId } = render(
<FormControl>
<Radio data-testid="root" />
</FormControl>,
);

expect(getByTestId('root')).not.to.have.class(classes.disabled);
});

it('should be overridden by props', () => {
const { getByTestId } = render(
<FormControl>
<Radio data-testid="root" disabled />
</FormControl>,
);

expect(getByTestId('root')).to.have.class(classes.disabled);
});
});

describe('disabled', () => {
it('should have the disabled class', () => {
const { getByTestId } = render(
<FormControl disabled>
<Radio data-testid="root" />
</FormControl>,
);

expect(getByTestId('root')).to.have.class(classes.disabled);
});

it('should be overridden by props', () => {
const { getByTestId } = render(
<FormControl disabled>
<Radio data-testid="root" disabled={false} />
</FormControl>,
);

expect(getByTestId('root')).not.to.have.class(classes.disabled);
});
});
});
});

0 comments on commit 8652b8e

Please sign in to comment.