Skip to content

Commit

Permalink
[Switch] 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 8652b8e commit 4580023
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 1 deletion.
1 change: 0 additions & 1 deletion packages/material-ui/src/Checkbox/Checkbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import Checkbox from './Checkbox';
import FormControl from '../FormControl';
import IconButton from '../IconButton';


describe('<Checkbox />', () => {
const render = createClientRender();
let classes;
Expand Down
47 changes: 47 additions & 0 deletions packages/material-ui/src/Switch/Switch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { expect } from 'chai';
import { createMount, getClasses } from '@material-ui/core/test-utils';
import describeConformance from '../test-utils/describeConformance';
import { createClientRender, fireEvent } from 'test/utils/createClientRender';
import FormControl from '../FormControl';
import Switch from './Switch';

describe('<Switch />', () => {
Expand Down Expand Up @@ -87,4 +88,50 @@ describe('<Switch />', () => {

expect(getByRole('checkbox')).to.have.property('checked', false);
});

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

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

it('should be overridden by props', () => {
const { getByTestId } = render(
<FormControl>
<Switch 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>
<Switch data-testid="root" />
</FormControl>,
);

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

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

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

0 comments on commit 4580023

Please sign in to comment.