@@ -3,6 +3,7 @@ import { expect } from 'chai';
3
3
import { createMount , getClasses } from '@material-ui/core/test-utils' ;
4
4
import describeConformance from '../test-utils/describeConformance' ;
5
5
import { createClientRender , fireEvent } from 'test/utils/createClientRender' ;
6
+ import FormControl from '../FormControl' ;
6
7
import Switch from './Switch' ;
7
8
8
9
describe ( '<Switch />' , ( ) => {
@@ -87,4 +88,50 @@ describe('<Switch />', () => {
87
88
88
89
expect ( getByRole ( 'checkbox' ) ) . to . have . property ( 'checked' , false ) ;
89
90
} ) ;
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
+ } ) ;
90
137
} ) ;
0 commit comments