1
1
import {
2
2
type BillingAddress ,
3
- type CheckoutInitialState ,
4
3
type CheckoutService ,
5
4
createCheckoutService ,
6
5
createEmbeddedCheckoutMessenger ,
@@ -40,7 +39,8 @@ import {
40
39
import { act , renderWithoutWrapper as render , screen } from '@bigcommerce/checkout/test-utils' ;
41
40
import { ThemeProvider } from '@bigcommerce/checkout/ui' ;
42
41
43
- import Checkout , { type CheckoutProps } from '../checkout/Checkout' ;
42
+ import Checkout from '../checkout/Checkout' ;
43
+ import { type CheckoutIntermediateProps } from '../checkout/CheckoutIntermediate' ;
44
44
import { getCheckoutPayment } from '../checkout/checkouts.mock' ;
45
45
import { createErrorLogger } from '../common/error' ;
46
46
import {
@@ -50,9 +50,9 @@ import {
50
50
51
51
describe ( 'Billing step' , ( ) => {
52
52
let checkout : CheckoutPageNodeObject ;
53
- let CheckoutTest : FunctionComponent < CheckoutProps > ;
53
+ let CheckoutTest : FunctionComponent < CheckoutIntermediateProps > ;
54
54
let checkoutService : CheckoutService ;
55
- let defaultProps : CheckoutProps & AnalyticsContextProps ;
55
+ let defaultProps : CheckoutIntermediateProps & AnalyticsContextProps ;
56
56
let embeddedMessengerMock : EmbeddedCheckoutMessenger ;
57
57
let analyticsTracker : Partial < AnalyticsEvents > ;
58
58
@@ -193,16 +193,15 @@ describe('Billing step', () => {
193
193
} ) ;
194
194
195
195
it ( 'should show order comments' , async ( ) => {
196
- checkoutService = createCheckoutService ( {
197
- initialState : {
198
- config : checkoutSettings ,
199
- checkout : {
200
- ...checkoutWithBillingEmail ,
201
- cart : checkoutWithDigitalCart . cart ,
202
- } ,
203
- formFields,
196
+ defaultProps . initialState = {
197
+ config : checkoutSettings ,
198
+ checkout : {
199
+ ...checkoutWithBillingEmail ,
200
+ cart : checkoutWithDigitalCart . cart ,
204
201
} ,
205
- } ) ;
202
+ formFields,
203
+ extensions : [ ] ,
204
+ } ;
206
205
207
206
render ( < CheckoutTest { ...defaultProps } /> ) ;
208
207
@@ -212,19 +211,18 @@ describe('Billing step', () => {
212
211
} ) ;
213
212
214
213
it ( 'should show PoweredByPayPalFastlaneLabel' , async ( ) => {
215
- checkoutService = createCheckoutService ( {
216
- initialState : {
217
- config : checkoutSettings ,
218
- checkout : {
219
- ...checkoutWithShipping ,
220
- billingAddress :checkoutWithBillingEmail . billingAddress ,
221
- payments :[
222
- getCheckoutPayment ( ) ,
223
- ] ,
224
- } ,
225
- formFields,
214
+ defaultProps . initialState = {
215
+ config : checkoutSettings ,
216
+ checkout : {
217
+ ...checkoutWithShipping ,
218
+ billingAddress :checkoutWithBillingEmail . billingAddress ,
219
+ payments :[
220
+ getCheckoutPayment ( ) ,
221
+ ] ,
226
222
} ,
227
- } ) ;
223
+ formFields,
224
+ extensions : [ ] ,
225
+ } ;
228
226
229
227
render ( < CheckoutTest { ...defaultProps } /> ) ;
230
228
@@ -302,13 +300,12 @@ describe('Billing step', () => {
302
300
303
301
describe ( 'registered customer' , ( ) => {
304
302
it ( 'completes the billing step after selecting a valid address' , async ( ) => {
305
- checkoutService = createCheckoutService ( {
306
- initialState : {
307
- config : checkoutSettings ,
308
- checkout : checkoutWithCustomer ,
309
- formFields,
310
- } ,
311
- } ) ;
303
+ defaultProps . initialState = {
304
+ config : checkoutSettings ,
305
+ checkout : checkoutWithCustomer ,
306
+ formFields,
307
+ extensions : [ ] ,
308
+ } ;
312
309
313
310
jest . spyOn ( checkoutService , 'updateBillingAddress' ) ;
314
311
@@ -368,13 +365,12 @@ describe('Billing step', () => {
368
365
phone : shippingAddress3 . phone ,
369
366
} as BillingAddress ;
370
367
371
- checkoutService = createCheckoutService ( {
372
- initialState : {
373
- config : checkoutSettings ,
374
- checkout : checkoutWithCustomer ,
375
- formFields,
376
- } ,
377
- } ) ;
368
+ defaultProps . initialState = {
369
+ config : checkoutSettings ,
370
+ checkout : checkoutWithCustomer ,
371
+ formFields,
372
+ extensions : [ ] ,
373
+ } ;
378
374
379
375
jest . spyOn ( checkoutService , 'updateBillingAddress' ) ;
380
376
@@ -423,13 +419,12 @@ describe('Billing step', () => {
423
419
} ) ;
424
420
425
421
it ( 'completes the billing step after creating a new address even with existing addresses' , async ( ) => {
426
- checkoutService = createCheckoutService ( {
427
- initialState : {
428
- config : checkoutSettings ,
429
- checkout : checkoutWithCustomer ,
430
- formFields,
431
- } ,
432
- } ) ;
422
+ defaultProps . initialState = {
423
+ config : checkoutSettings ,
424
+ checkout : checkoutWithCustomer ,
425
+ formFields,
426
+ extensions : [ ] ,
427
+ } ;
433
428
434
429
jest . spyOn ( checkoutService , 'updateBillingAddress' ) ;
435
430
0 commit comments