@@ -20,14 +20,18 @@ describe('Popup', () => {
2020 const props = { visible : false } ;
2121 const state = { prevVisible : null , status : 'something' } ;
2222
23- expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe ( 'stable' ) ;
23+ expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe (
24+ 'stable' ,
25+ ) ;
2426 } ) ;
2527
2628 it ( 'does not change when visible is unchanged' , ( ) => {
2729 const props = { visible : true } ;
2830 const state = { prevVisible : true , status : 'something' } ;
2931
30- expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe ( 'something' ) ;
32+ expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe (
33+ 'something' ,
34+ ) ;
3135 } ) ;
3236
3337 it ( 'returns null when visible is changed to true' , ( ) => {
@@ -41,7 +45,9 @@ describe('Popup', () => {
4145 const props = { visible : false } ;
4246 const state = { prevVisible : true , status : 'something' } ;
4347
44- expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe ( 'stable' ) ;
48+ expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe (
49+ 'stable' ,
50+ ) ;
4551 } ) ;
4652
4753 it ( 'returns null when visible is changed to false and motion is started' , ( ) => {
@@ -51,7 +57,7 @@ describe('Popup', () => {
5157 motionName : 'enter' ,
5258 } ,
5359 } ;
54- const state = { prevVisible : true , status : 'motion' } ;
60+ const state = { prevVisible : true , status : 'motion' , inMotion : true } ;
5561
5662 expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe ( null ) ;
5763 } ) ;
@@ -65,7 +71,9 @@ describe('Popup', () => {
6571 } ;
6672 const state = { prevVisible : true , status : 'beforeMotion' } ;
6773
68- expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe ( 'stable' ) ;
74+ expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe (
75+ 'stable' ,
76+ ) ;
6977 } ) ;
7078 } ) ;
7179
@@ -82,4 +90,22 @@ describe('Popup', () => {
8290 wrapper . setProps ( { visible : false } ) ;
8391 expect ( raf . cancel ) . toHaveBeenCalledTimes ( 1 ) ;
8492 } ) ;
93+
94+ it ( 'not crash on motion with event' , ( ) => {
95+ const onEnterStart = jest . fn ( ) ;
96+
97+ const wrapper = mount (
98+ < Popup visible motion = { { motionName : 'light' , onEnterStart } } >
99+ < div > popup content</ div >
100+ </ Popup > ,
101+ ) ;
102+
103+ // Trigger once
104+ wrapper
105+ . find ( 'CSSMotion' )
106+ . props ( )
107+ . onEnterStart ( ) ;
108+
109+ expect ( onEnterStart ) . toHaveBeenCalledTimes ( 1 ) ;
110+ } ) ;
85111} ) ;
0 commit comments