@@ -6,6 +6,7 @@ import ButtonBase from '@mui/material/ButtonBase';
66import { ThemeProvider , createTheme } from '@mui/material/styles' ;
77import switchBaseClasses from '../internal/switchBaseClasses' ;
88import describeConformance from '../../test/describeConformance' ;
9+ import * as ripple from '../../test/ripple' ;
910
1011describe ( '<Radio />' , ( ) => {
1112 const { render } = createRenderer ( ) ;
@@ -146,4 +147,52 @@ describe('<Radio />', () => {
146147
147148 expect ( screen . queryByRole ( 'radio' , { name : 'A' } ) ) . not . to . equal ( null ) ;
148149 } ) ;
150+
151+ describe ( 'prop: disableRipple' , ( ) => {
152+ it ( 'should have a ripple by default' , async ( ) => {
153+ render ( < Radio TouchRippleProps = { { className : 'touch-ripple' } } /> ) ;
154+
155+ const radio = screen . getByRole ( 'radio' ) . parentElement ;
156+ await ripple . startTouch ( radio ) ;
157+ expect ( radio . querySelector ( '.touch-ripple' ) ) . not . to . equal ( null ) ;
158+ } ) ;
159+
160+ it ( 'should not have a ripple when disableRipple is set' , async ( ) => {
161+ render ( < Radio disableRipple TouchRippleProps = { { className : 'touch-ripple' } } /> ) ;
162+
163+ const radio = screen . getByRole ( 'radio' ) . parentElement ;
164+ await ripple . startTouch ( radio ) ;
165+ expect ( radio . querySelector ( '.touch-ripple' ) ) . to . equal ( null ) ;
166+ } ) ;
167+
168+ it ( 'should respect a global disableRipple from MuiButtonBase defaultProps' , async ( ) => {
169+ const theme = createTheme ( {
170+ components : { MuiButtonBase : { defaultProps : { disableRipple : true } } } ,
171+ } ) ;
172+ render (
173+ < ThemeProvider theme = { theme } >
174+ < Radio TouchRippleProps = { { className : 'touch-ripple' } } />
175+ </ ThemeProvider > ,
176+ ) ;
177+
178+ const radio = screen . getByRole ( 'radio' ) . parentElement ;
179+ await ripple . startTouch ( radio ) ;
180+ expect ( radio . querySelector ( '.touch-ripple' ) ) . to . equal ( null ) ;
181+ } ) ;
182+
183+ it ( 'should let an explicit disableRipple={false} override a global disableRipple' , async ( ) => {
184+ const theme = createTheme ( {
185+ components : { MuiButtonBase : { defaultProps : { disableRipple : true } } } ,
186+ } ) ;
187+ render (
188+ < ThemeProvider theme = { theme } >
189+ < Radio disableRipple = { false } TouchRippleProps = { { className : 'touch-ripple' } } />
190+ </ ThemeProvider > ,
191+ ) ;
192+
193+ const radio = screen . getByRole ( 'radio' ) . parentElement ;
194+ await ripple . startTouch ( radio ) ;
195+ expect ( radio . querySelector ( '.touch-ripple' ) ) . not . to . equal ( null ) ;
196+ } ) ;
197+ } ) ;
149198} ) ;
0 commit comments