@@ -3,6 +3,7 @@ import { expect } from 'chai';
33import { createMount , getClasses } from '@material-ui/core/test-utils' ;
44import describeConformance from '../test-utils/describeConformance' ;
55import { createClientRender , fireEvent } from 'test/utils/createClientRender' ;
6+ import FormControl from '../FormControl' ;
67import Switch from './Switch' ;
78
89describe ( '<Switch />' , ( ) => {
@@ -87,4 +88,50 @@ describe('<Switch />', () => {
8788
8889 expect ( getByRole ( 'checkbox' ) ) . to . have . property ( 'checked' , false ) ;
8990 } ) ;
91+
92+ describe ( 'with FormControl' , ( ) => {
93+ describe ( 'enabled' , ( ) => {
94+ it ( 'should not have the disabled class' , ( ) => {
95+ const { getByTestId } = render (
96+ < FormControl >
97+ < Switch data-testid = "root" />
98+ </ FormControl > ,
99+ ) ;
100+
101+ expect ( getByTestId ( 'root' ) ) . not . to . have . class ( classes . disabled ) ;
102+ } ) ;
103+
104+ it ( 'should be overridden by props' , ( ) => {
105+ const { getByTestId } = render (
106+ < FormControl >
107+ < Switch data-testid = "root" disabled />
108+ </ FormControl > ,
109+ ) ;
110+
111+ expect ( getByTestId ( 'root' ) ) . to . have . class ( classes . disabled ) ;
112+ } ) ;
113+ } ) ;
114+
115+ describe ( 'disabled' , ( ) => {
116+ it ( 'should have the disabled class' , ( ) => {
117+ const { getByTestId } = render (
118+ < FormControl disabled >
119+ < Switch data-testid = "root" />
120+ </ FormControl > ,
121+ ) ;
122+
123+ expect ( getByTestId ( 'root' ) ) . to . have . class ( classes . disabled ) ;
124+ } ) ;
125+
126+ it ( 'should be overridden by props' , ( ) => {
127+ const { getByTestId } = render (
128+ < FormControl disabled >
129+ < Switch data-testid = "root" disabled = { false } />
130+ </ FormControl > ,
131+ ) ;
132+
133+ expect ( getByTestId ( 'root' ) ) . not . to . have . class ( classes . disabled ) ;
134+ } ) ;
135+ } ) ;
136+ } ) ;
90137} ) ;
0 commit comments