@@ -397,24 +397,37 @@ describe('PayPalCommerceButtonStrategy', () => {
397397 } ) ;
398398
399399 it ( 'calls PayPal button resume' , async ( ) => {
400+ const paymentMethodWithShippingOptionsFeature = {
401+ ...paymentMethod ,
402+ initializationData : {
403+ ...paymentMethod . initializationData ,
404+ isAppSwitchEnabled : true ,
405+ } ,
406+ } ;
407+
400408 jest . spyOn (
401409 paymentIntegrationService . getState ( ) ,
402- 'getStoreConfigOrThrow' ,
403- ) . mockReturnValue ( {
404- ...storeConfig ,
405- checkoutSettings : {
406- ...storeConfig . checkoutSettings ,
407- features : {
408- 'PAYPAL-5716.app_switch_functionality' : true ,
409- } ,
410- } ,
411- } ) ;
410+ 'getPaymentMethodOrThrow' ,
411+ ) . mockReturnValue ( paymentMethodWithShippingOptionsFeature ) ;
412412 await strategy . initialize ( initializationOptions ) ;
413413
414414 expect ( resumeMock ) . toHaveBeenCalled ( ) ;
415415 } ) ;
416416
417417 it ( 'initializes PayPal button to render (buy now flow)' , async ( ) => {
418+ const paymentMethodWithShippingOptionsFeature = {
419+ ...paymentMethod ,
420+ initializationData : {
421+ ...paymentMethod . initializationData ,
422+ isAppSwitchEnabled : true ,
423+ } ,
424+ } ;
425+
426+ jest . spyOn (
427+ paymentIntegrationService . getState ( ) ,
428+ 'getPaymentMethodOrThrow' ,
429+ ) . mockReturnValue ( paymentMethodWithShippingOptionsFeature ) ;
430+ await strategy . initialize ( initializationOptions ) ;
418431 await strategy . initialize ( buyNowInitializationOptions ) ;
419432
420433 expect ( paypalSdk . Buttons ) . toHaveBeenCalledWith ( {
@@ -485,10 +498,11 @@ describe('PayPalCommerceButtonStrategy', () => {
485498 await strategy . initialize ( initializationOptions ) ;
486499
487500 expect ( paypalSdk . Buttons ) . toHaveBeenCalledWith ( {
488- fundingSource : paypalSdk . FUNDING . PAYPAL ,
489- style : paypalCommerceOptions . style ,
501+ appSwitchWhenAvailable : true ,
490502 createOrder : expect . any ( Function ) ,
503+ fundingSource : paypalSdk . FUNDING . PAYPAL ,
491504 onApprove : expect . any ( Function ) ,
505+ style : paypalCommerceOptions . style ,
492506 } ) ;
493507 } ) ;
494508
@@ -557,26 +571,27 @@ describe('PayPalCommerceButtonStrategy', () => {
557571 } ) ;
558572
559573 it ( 'initializes PayPal button to render with appSwitch flag' , async ( ) => {
574+ const paymentMethodWithShippingOptionsFeature = {
575+ ...paymentMethod ,
576+ initializationData : {
577+ ...paymentMethod . initializationData ,
578+ isAppSwitchEnabled : true ,
579+ } ,
580+ } ;
581+
560582 jest . spyOn (
561583 paymentIntegrationService . getState ( ) ,
562- 'getStoreConfigOrThrow' ,
563- ) . mockReturnValue ( {
564- ...storeConfig ,
565- checkoutSettings : {
566- ...storeConfig . checkoutSettings ,
567- features : {
568- 'PAYPAL-5716.app_switch_functionality' : true ,
569- } ,
570- } ,
571- } ) ;
584+ 'getPaymentMethodOrThrow' ,
585+ ) . mockReturnValue ( paymentMethodWithShippingOptionsFeature ) ;
586+ await strategy . initialize ( initializationOptions ) ;
572587 await strategy . initialize ( initializationOptions ) ;
573588
574589 expect ( paypalSdk . Buttons ) . toHaveBeenCalledWith ( {
575590 appSwitchWhenAvailable : true ,
576- fundingSource : paypalSdk . FUNDING . PAYPAL ,
577- style : paypalCommerceOptions . style ,
578591 createOrder : expect . any ( Function ) ,
592+ fundingSource : paypalSdk . FUNDING . PAYPAL ,
579593 onApprove : expect . any ( Function ) ,
594+ style : paypalCommerceOptions . style ,
580595 } ) ;
581596 } ) ;
582597 } ) ;
0 commit comments