11import {
22 type BillingAddress ,
3+ type CheckoutInitialState ,
34 type CheckoutService ,
45 createCheckoutService ,
56 createEmbeddedCheckoutMessenger ,
@@ -23,12 +24,14 @@ import {
2324import {
2425 CheckoutPageNodeObject ,
2526 CheckoutPreset ,
27+ checkoutSettings ,
2628 checkoutWithBillingEmail ,
2729 checkoutWithDigitalCart ,
2830 checkoutWithShipping ,
2931 checkoutWithShippingAndBilling ,
3032 consignment ,
3133 customer ,
34+ formFields ,
3235 payments ,
3336 shippingAddress ,
3437 shippingAddress2 ,
@@ -128,7 +131,9 @@ describe('Billing step', () => {
128131 } ) ;
129132
130133 it ( 'completes the billing step as a guest and goes to the payment step' , async ( ) => {
131- checkout . use ( CheckoutPreset . CheckoutWithShipping ) ;
134+ checkoutService = checkout . use ( CheckoutPreset . CheckoutWithShipping ) ;
135+
136+ jest . spyOn ( checkoutService , 'updateBillingAddress' ) ;
132137
133138 render ( < CheckoutTest { ...defaultProps } /> ) ;
134139
@@ -153,7 +158,9 @@ describe('Billing step', () => {
153158 } ) ;
154159
155160 it ( 'edit the billing address and goes back to the payment step' , async ( ) => {
156- checkout . use ( CheckoutPreset . CheckoutWithShippingAndBilling ) ;
161+ checkoutService = checkout . use ( CheckoutPreset . CheckoutWithShippingAndBilling ) ;
162+
163+ jest . spyOn ( checkoutService , 'updateBillingAddress' ) ;
157164
158165 render ( < CheckoutTest { ...defaultProps } /> ) ;
159166
@@ -186,14 +193,16 @@ describe('Billing step', () => {
186193 } ) ;
187194
188195 it ( 'should show order comments' , async ( ) => {
189- checkout . updateCheckout (
190- 'get' ,
191- '/checkout/*' ,
192- {
193- ...checkoutWithBillingEmail ,
194- cart : checkoutWithDigitalCart . cart ,
196+ checkoutService = createCheckoutService ( {
197+ initialState : {
198+ config : checkoutSettings ,
199+ checkout : {
200+ ...checkoutWithBillingEmail ,
201+ cart : checkoutWithDigitalCart . cart ,
202+ } ,
203+ formFields,
195204 } ,
196- ) ;
205+ } ) ;
197206
198207 render ( < CheckoutTest { ...defaultProps } /> ) ;
199208
@@ -203,17 +212,19 @@ describe('Billing step', () => {
203212 } ) ;
204213
205214 it ( 'should show PoweredByPayPalFastlaneLabel' , async ( ) => {
206- checkout . updateCheckout (
207- 'get' ,
208- '/checkout/*' ,
209- {
210- ...checkoutWithShipping ,
211- billingAddress :checkoutWithBillingEmail . billingAddress ,
212- payments :[
213- getCheckoutPayment ( ) ,
214- ] ,
215+ checkoutService = createCheckoutService ( {
216+ initialState : {
217+ config : checkoutSettings ,
218+ checkout : {
219+ ...checkoutWithShipping ,
220+ billingAddress :checkoutWithBillingEmail . billingAddress ,
221+ payments :[
222+ getCheckoutPayment ( ) ,
223+ ] ,
224+ } ,
225+ formFields,
215226 } ,
216- ) ;
227+ } ) ;
217228
218229 render ( < CheckoutTest { ...defaultProps } /> ) ;
219230
@@ -223,11 +234,9 @@ describe('Billing step', () => {
223234 } ) ;
224235
225236 it ( 'should show PoweredByPayPalFastlaneLabel and custom form fields' , async ( ) => {
226- checkout . use ( CheckoutPreset . CheckoutWithBillingEmailAndCustomFormFields ) ;
227- checkout . updateCheckout (
228- 'get' ,
229- '/checkout/*' ,
230- {
237+ checkoutService = checkout . use ( CheckoutPreset . CheckoutWithBillingEmailAndCustomFormFields , {
238+ config : checkoutSettings ,
239+ checkout : {
231240 ...checkoutWithShipping ,
232241 billingAddress :checkoutWithBillingEmail . billingAddress ,
233242 consignments : [
@@ -273,7 +282,8 @@ describe('Billing step', () => {
273282 getCheckoutPayment ( ) ,
274283 ] ,
275284 } ,
276- ) ;
285+ formFields,
286+ } ) ;
277287
278288 render ( < CheckoutTest { ...defaultProps } /> ) ;
279289
@@ -292,11 +302,15 @@ describe('Billing step', () => {
292302
293303 describe ( 'registered customer' , ( ) => {
294304 it ( 'completes the billing step after selecting a valid address' , async ( ) => {
295- checkout . updateCheckout (
296- 'get' ,
297- '/checkout/*' ,
298- checkoutWithCustomer
299- ) ;
305+ checkoutService = createCheckoutService ( {
306+ initialState : {
307+ config : checkoutSettings ,
308+ checkout : checkoutWithCustomer ,
309+ formFields,
310+ } ,
311+ } ) ;
312+
313+ jest . spyOn ( checkoutService , 'updateBillingAddress' ) ;
300314
301315 render ( < CheckoutTest { ...defaultProps } /> ) ;
302316
@@ -354,11 +368,15 @@ describe('Billing step', () => {
354368 phone : shippingAddress3 . phone ,
355369 } as BillingAddress ;
356370
357- checkout . updateCheckout (
358- 'get' ,
359- '/checkout/*' ,
360- checkoutWithCustomer
361- ) ;
371+ checkoutService = createCheckoutService ( {
372+ initialState : {
373+ config : checkoutSettings ,
374+ checkout : checkoutWithCustomer ,
375+ formFields,
376+ } ,
377+ } ) ;
378+
379+ jest . spyOn ( checkoutService , 'updateBillingAddress' ) ;
362380
363381 render ( < CheckoutTest { ...defaultProps } /> ) ;
364382
@@ -405,11 +423,15 @@ describe('Billing step', () => {
405423 } ) ;
406424
407425 it ( 'completes the billing step after creating a new address even with existing addresses' , async ( ) => {
408- checkout . updateCheckout (
409- 'get' ,
410- '/checkout/*' ,
411- checkoutWithCustomer
412- ) ;
426+ checkoutService = createCheckoutService ( {
427+ initialState : {
428+ config : checkoutSettings ,
429+ checkout : checkoutWithCustomer ,
430+ formFields,
431+ } ,
432+ } ) ;
433+
434+ jest . spyOn ( checkoutService , 'updateBillingAddress' ) ;
413435
414436 render ( < CheckoutTest { ...defaultProps } /> ) ;
415437
0 commit comments