@@ -280,24 +280,48 @@ describe('dialog', () => {
280
280
} ) ;
281
281
} ) ;
282
282
283
- it ( 'sets transform-origin when property mousePosition is set' , ( ) => {
284
- const wrapper = mount (
285
- < Dialog style = { { width : 600 } } mousePosition = { { x : 100 , y : 100 } } visible >
286
- < p > the dialog</ p >
287
- </ Dialog > ,
288
- ) ;
283
+ describe ( 'mousePosition' , ( ) => {
284
+ function prepareModal ( mousePosition : { x : number ; y : number } ) {
285
+ const wrapper = mount (
286
+ < Dialog style = { { width : 600 } } mousePosition = { mousePosition } visible >
287
+ < p > the dialog</ p >
288
+ </ Dialog > ,
289
+ ) ;
290
+
291
+ // Trigger position align
292
+ act ( ( ) => {
293
+ wrapper
294
+ . find < any > ( 'Content CSSMotion' as any )
295
+ . props ( )
296
+ . onAppearPrepare ( ) ;
297
+ } ) ;
298
+
299
+ return wrapper ;
300
+ }
301
+
302
+ it ( 'sets transform-origin when property mousePosition is set' , ( ) => {
303
+ const wrapper = prepareModal ( { x : 100 , y : 100 } ) ;
304
+
305
+ expect (
306
+ ( wrapper . find ( '.rc-dialog' ) . at ( 0 ) . getDOMNode ( ) as HTMLDivElement ) . style [ 'transform-origin' ] ,
307
+ ) . toBeTruthy ( ) ;
308
+ } ) ;
289
309
290
- // Trigger position align
291
- act ( ( ) => {
292
- wrapper
293
- . find < any > ( 'Content CSSMotion' as any )
294
- . props ( )
295
- . onAppearPrepare ( ) ;
310
+ it ( 'both undefined' , ( ) => {
311
+ const wrapper = prepareModal ( { x : undefined , y : undefined } ) ;
312
+
313
+ expect (
314
+ ( wrapper . find ( '.rc-dialog' ) . at ( 0 ) . getDOMNode ( ) as HTMLDivElement ) . style [ 'transform-origin' ] ,
315
+ ) . toBeFalsy ( ) ;
296
316
} ) ;
297
317
298
- expect (
299
- ( wrapper . find ( '.rc-dialog' ) . at ( 0 ) . getDOMNode ( ) as HTMLDivElement ) . style [ 'transform-origin' ] ,
300
- ) . toBeTruthy ( ) ;
318
+ it ( 'one valid' , ( ) => {
319
+ const wrapper = prepareModal ( { x : 10 , y : 0 } ) ;
320
+
321
+ expect (
322
+ ( wrapper . find ( '.rc-dialog' ) . at ( 0 ) . getDOMNode ( ) as HTMLDivElement ) . style [ 'transform-origin' ] ,
323
+ ) . toBeTruthy ( ) ;
324
+ } ) ;
301
325
} ) ;
302
326
303
327
it ( 'can get dom element before dialog first show when forceRender is set true ' , ( ) => {
@@ -644,14 +668,14 @@ describe('dialog', () => {
644
668
it ( 'support aria-* in closable' , ( ) => {
645
669
const onClose = jest . fn ( ) ;
646
670
const wrapper = mount (
647
- < Dialog
671
+ < Dialog
648
672
closable = { {
649
- closeIcon :" test" ,
673
+ closeIcon : ' test' ,
650
674
'aria-label' : 'test aria-label' ,
651
- } }
652
- visible
653
- onClose = { onClose }
654
- />
675
+ } }
676
+ visible
677
+ onClose = { onClose }
678
+ /> ,
655
679
) ;
656
680
jest . runAllTimers ( ) ;
657
681
wrapper . update ( ) ;
@@ -669,14 +693,14 @@ describe('dialog', () => {
669
693
it ( 'support disable button in closable' , ( ) => {
670
694
const onClose = jest . fn ( ) ;
671
695
const wrapper = mount (
672
- < Dialog
696
+ < Dialog
673
697
closable = { {
674
- closeIcon :" test" ,
698
+ closeIcon : ' test' ,
675
699
disabled : true ,
676
- } }
677
- visible
678
- onClose = { onClose }
679
- />
700
+ } }
701
+ visible
702
+ onClose = { onClose }
703
+ /> ,
680
704
) ;
681
705
jest . runAllTimers ( ) ;
682
706
wrapper . update ( ) ;
@@ -697,13 +721,7 @@ describe('dialog', () => {
697
721
698
722
it ( 'should not display closeIcon when closable is false' , ( ) => {
699
723
const onClose = jest . fn ( ) ;
700
- const wrapper = mount (
701
- < Dialog
702
- closable = { false }
703
- visible
704
- onClose = { onClose }
705
- />
706
- ) ;
724
+ const wrapper = mount ( < Dialog closable = { false } visible onClose = { onClose } /> ) ;
707
725
jest . runAllTimers ( ) ;
708
726
wrapper . update ( ) ;
709
727
0 commit comments