File tree Expand file tree Collapse file tree 1 file changed +81
-0
lines changed Expand file tree Collapse file tree 1 file changed +81
-0
lines changed Original file line number Diff line number Diff line change @@ -312,4 +312,85 @@ describe('dialog', () => {
312312 expect ( $ ( '.rc-dialog-body > div' ) . text ( ) ) . to . be ( 'forceRender element' ) ;
313313 expect ( $ ( '.rc-dialog-wrap' ) [ 0 ] . style . display ) . to . be ( '' ) ;
314314 } )
315+ it ( 'Single Dialog body overflow set correctly' , ( ) => {
316+ document . body . style . overflow = "scroll"
317+
318+ dialog . setState ( {
319+ visible : true
320+ } ) ;
321+ expect ( document . body . style . overflow ) . to . be ( 'hidden' ) ;
322+
323+ dialog . setState ( {
324+ visible : false
325+ } ) ;
326+ expect ( document . body . style . overflow ) . to . be ( 'scroll' ) ;
327+ } )
328+
329+ it ( 'Multiple Dialog body overflow set correctly' , ( ) => {
330+ document . body . style . overflow = "scroll"
331+
332+ class MultipleDialogWrap extends React . Component {
333+ state = {
334+ visible : false ,
335+ visible2 : false ,
336+ } ;
337+ render ( ) {
338+ return (
339+ < div >
340+ < Dialog
341+ { ...this . props }
342+ visible = { this . state . visible }
343+ />
344+ < Dialog
345+ { ...this . props }
346+ visible = { this . state . visible2 }
347+ />
348+ </ div >
349+ ) ;
350+ }
351+ }
352+
353+ const d = ReactDOM . render ( (
354+ < MultipleDialogWrap >
355+ < div > forceRender element</ div >
356+ </ MultipleDialogWrap >
357+ ) , container ) ;
358+
359+ expect ( $ ( '.rc-dialog' ) . length ) . to . be ( 0 ) ;
360+
361+ d . setState ( {
362+ visible : true ,
363+ } )
364+ expect ( $ ( '.rc-dialog' ) . length ) . to . be ( 1 ) ;
365+ expect ( document . body . style . overflow ) . to . be ( 'hidden' ) ;
366+
367+ d . setState ( {
368+ visible2 : true ,
369+ } )
370+ expect ( $ ( '.rc-dialog' ) . length ) . to . be ( 2 ) ;
371+ expect ( document . body . style . overflow ) . to . be ( 'hidden' ) ;
372+
373+ d . setState ( {
374+ visible : false ,
375+ visible2 : false ,
376+ } )
377+ expect ( document . body . style . overflow ) . to . be ( 'scroll' ) ;
378+
379+ d . setState ( {
380+ visible : true ,
381+ } )
382+ expect ( document . body . style . overflow ) . to . be ( 'hidden' ) ;
383+
384+ d . setState ( {
385+ visible : false ,
386+ visible2 : true ,
387+ } )
388+ expect ( document . body . style . overflow ) . to . be ( 'hidden' ) ;
389+
390+ d . setState ( {
391+ visible : false ,
392+ visible2 : false ,
393+ } )
394+ expect ( document . body . style . overflow ) . to . be ( 'scroll' ) ;
395+ } )
315396} ) ;
You can’t perform that action at this time.
0 commit comments