@@ -53,9 +53,7 @@ describe('Elements', () => {
53
53
expect ( mockStripe . elements ) . toHaveBeenCalledTimes ( 1 ) ;
54
54
} ) ;
55
55
56
- // TODO(christopher): support Strict Mode first
57
- // eslint-disable-next-line jest/no-disabled-tests
58
- test . skip ( 'only creates elements once in Strict Mode' , ( ) => {
56
+ test ( 'only creates elements once in Strict Mode' , ( ) => {
59
57
const TestComponent = ( ) => {
60
58
const _ = useElements ( ) ;
61
59
return < div /> ;
@@ -83,39 +81,39 @@ describe('Elements', () => {
83
81
} ) ;
84
82
85
83
test ( 'provides elements and stripe with the ElementsConsumer component' , ( ) => {
86
- expect . assertions ( 2 ) ;
84
+ const spy = jest . fn ( )
87
85
88
86
render (
89
87
< Elements stripe = { mockStripe } >
90
88
< ElementsConsumer >
91
89
{ ( ctx ) => {
92
- expect ( ctx . elements ) . toBe ( mockElements ) ;
93
- expect ( ctx . stripe ) . toBe ( mockStripe ) ;
94
-
90
+ spy ( ctx )
95
91
return null ;
96
92
} }
97
93
</ ElementsConsumer >
98
94
</ Elements >
99
95
) ;
96
+
97
+ expect ( spy ) . toBeCalledWith ( { stripe : mockStripe , elements : mockElements } ) ;
100
98
} ) ;
101
99
102
100
test ( 'provides elements and stripe with the ElementsConsumer component in Strict Mode' , ( ) => {
103
- expect . assertions ( 2 ) ;
101
+ const spy = jest . fn ( )
104
102
105
103
render (
106
104
< React . StrictMode >
107
- < Elements stripe = { mockStripe } >
108
- < ElementsConsumer >
109
- { ( ctx ) => {
110
- expect ( ctx . elements ) . toBe ( mockElements ) ;
111
- expect ( ctx . stripe ) . toBe ( mockStripe ) ;
112
-
113
- return null ;
114
- } }
115
- </ ElementsConsumer >
116
- </ Elements >
105
+ < Elements stripe = { mockStripe } >
106
+ < ElementsConsumer >
107
+ { ( ctx ) => {
108
+ spy ( ctx )
109
+ return null ;
110
+ } }
111
+ </ ElementsConsumer >
112
+ </ Elements >
117
113
</ React . StrictMode >
118
114
) ;
115
+
116
+ expect ( spy ) . toBeCalledWith ( { stripe : mockStripe , elements : mockElements } ) ;
119
117
} ) ;
120
118
121
119
test ( 'provides given stripe instance on mount' , ( ) => {
@@ -159,8 +157,8 @@ describe('Elements', () => {
159
157
< React . StrictMode >
160
158
< Elements stripe = { stripeProp } >
161
159
< ElementsConsumer >
162
- { ( { stripe , elements } ) => {
163
- spy ( { stripe , elements } ) ;
160
+ { ( ctx ) => {
161
+ spy ( ctx )
164
162
return null ;
165
163
} }
166
164
</ ElementsConsumer >
0 commit comments