@@ -20,14 +20,18 @@ describe('Popup', () => {
20
20
const props = { visible : false } ;
21
21
const state = { prevVisible : null , status : 'something' } ;
22
22
23
- expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe ( 'stable' ) ;
23
+ expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe (
24
+ 'stable' ,
25
+ ) ;
24
26
} ) ;
25
27
26
28
it ( 'does not change when visible is unchanged' , ( ) => {
27
29
const props = { visible : true } ;
28
30
const state = { prevVisible : true , status : 'something' } ;
29
31
30
- expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe ( 'something' ) ;
32
+ expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe (
33
+ 'something' ,
34
+ ) ;
31
35
} ) ;
32
36
33
37
it ( 'returns null when visible is changed to true' , ( ) => {
@@ -41,7 +45,9 @@ describe('Popup', () => {
41
45
const props = { visible : false } ;
42
46
const state = { prevVisible : true , status : 'something' } ;
43
47
44
- expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe ( 'stable' ) ;
48
+ expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe (
49
+ 'stable' ,
50
+ ) ;
45
51
} ) ;
46
52
47
53
it ( 'returns null when visible is changed to false and motion is started' , ( ) => {
@@ -51,7 +57,7 @@ describe('Popup', () => {
51
57
motionName : 'enter' ,
52
58
} ,
53
59
} ;
54
- const state = { prevVisible : true , status : 'motion' } ;
60
+ const state = { prevVisible : true , status : 'motion' , inMotion : true } ;
55
61
56
62
expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe ( null ) ;
57
63
} ) ;
@@ -65,7 +71,9 @@ describe('Popup', () => {
65
71
} ;
66
72
const state = { prevVisible : true , status : 'beforeMotion' } ;
67
73
68
- expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe ( 'stable' ) ;
74
+ expect ( Popup . getDerivedStateFromProps ( props , state ) . status ) . toBe (
75
+ 'stable' ,
76
+ ) ;
69
77
} ) ;
70
78
} ) ;
71
79
@@ -82,4 +90,22 @@ describe('Popup', () => {
82
90
wrapper . setProps ( { visible : false } ) ;
83
91
expect ( raf . cancel ) . toHaveBeenCalledTimes ( 1 ) ;
84
92
} ) ;
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
+ } ) ;
85
111
} ) ;
0 commit comments