@@ -53,9 +53,7 @@ describe('Elements', () => {
5353 expect ( mockStripe . elements ) . toHaveBeenCalledTimes ( 1 ) ;
5454 } ) ;
5555
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' , ( ) => {
5957 const TestComponent = ( ) => {
6058 const _ = useElements ( ) ;
6159 return < div /> ;
@@ -83,39 +81,39 @@ describe('Elements', () => {
8381 } ) ;
8482
8583 test ( 'provides elements and stripe with the ElementsConsumer component' , ( ) => {
86- expect . assertions ( 2 ) ;
84+ const spy = jest . fn ( )
8785
8886 render (
8987 < Elements stripe = { mockStripe } >
9088 < ElementsConsumer >
9189 { ( ctx ) => {
92- expect ( ctx . elements ) . toBe ( mockElements ) ;
93- expect ( ctx . stripe ) . toBe ( mockStripe ) ;
94-
90+ spy ( ctx )
9591 return null ;
9692 } }
9793 </ ElementsConsumer >
9894 </ Elements >
9995 ) ;
96+
97+ expect ( spy ) . toBeCalledWith ( { stripe : mockStripe , elements : mockElements } ) ;
10098 } ) ;
10199
102100 test ( 'provides elements and stripe with the ElementsConsumer component in Strict Mode' , ( ) => {
103- expect . assertions ( 2 ) ;
101+ const spy = jest . fn ( )
104102
105103 render (
106104 < 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 >
117113 </ React . StrictMode >
118114 ) ;
115+
116+ expect ( spy ) . toBeCalledWith ( { stripe : mockStripe , elements : mockElements } ) ;
119117 } ) ;
120118
121119 test ( 'provides given stripe instance on mount' , ( ) => {
@@ -159,8 +157,8 @@ describe('Elements', () => {
159157 < React . StrictMode >
160158 < Elements stripe = { stripeProp } >
161159 < ElementsConsumer >
162- { ( { stripe , elements } ) => {
163- spy ( { stripe , elements } ) ;
160+ { ( ctx ) => {
161+ spy ( ctx )
164162 return null ;
165163 } }
166164 </ ElementsConsumer >
0 commit comments