11/* eslint-disable no-new */
2+ /* eslint-disable no-console */
23
34import {
45 LifecycleEventParseError ,
@@ -772,10 +773,15 @@ describe('ShopifyCheckoutSheetKit', () => {
772773 ...acceleratedConfig ,
773774 storefrontDomain : '' ,
774775 } ;
776+ const expectedError = new Error ( '`storefrontDomain` is required' ) ;
775777
776778 await expect (
777779 instance . configureAcceleratedCheckouts ( invalidConfig ) ,
778- ) . rejects . toThrow ( 'storefrontDomain is required' ) ;
780+ ) . resolves . toBe ( false ) ;
781+ expect ( console . error ) . toHaveBeenCalledWith (
782+ '[ShopifyCheckoutSheetKit] Failed to configure accelerated checkouts with' ,
783+ expectedError ,
784+ ) ;
779785 } ) ;
780786
781787 it ( 'validates required storefrontAccessToken' , async ( ) => {
@@ -785,9 +791,15 @@ describe('ShopifyCheckoutSheetKit', () => {
785791 storefrontAccessToken : '' ,
786792 } ;
787793
794+ const expectedError = new Error ( '`storefrontAccessToken` is required' ) ;
795+
788796 await expect (
789797 instance . configureAcceleratedCheckouts ( invalidConfig ) ,
790- ) . rejects . toThrow ( 'storefrontAccessToken is required' ) ;
798+ ) . resolves . toBe ( false ) ;
799+ expect ( console . error ) . toHaveBeenCalledWith (
800+ '[ShopifyCheckoutSheetKit] Failed to configure accelerated checkouts with' ,
801+ expectedError ,
802+ ) ;
791803 } ) ;
792804
793805 it ( 'validates required merchantIdentifier when Apple Pay is configured' , async ( ) => {
@@ -802,9 +814,42 @@ describe('ShopifyCheckoutSheetKit', () => {
802814 } ,
803815 } ;
804816
817+ const expectedError = new Error (
818+ '`wallets.applePay.merchantIdentifier` is required' ,
819+ ) ;
820+
805821 await expect (
806822 instance . configureAcceleratedCheckouts ( invalidConfig ) ,
807- ) . rejects . toThrow ( 'wallets.applePay.merchantIdentifier is required' ) ;
823+ ) . resolves . toBe ( false ) ;
824+ expect ( console . error ) . toHaveBeenCalledWith (
825+ '[ShopifyCheckoutSheetKit] Failed to configure accelerated checkouts with' ,
826+ expectedError ,
827+ ) ;
828+ } ) ;
829+
830+ it ( 'validates required contactFields when Apple Pay is configured' , async ( ) => {
831+ const instance = new ShopifyCheckoutSheet ( ) ;
832+ const invalidConfig = {
833+ ...acceleratedConfig ,
834+ wallets : {
835+ applePay : {
836+ contactFields : [ 'invalid' ] ,
837+ merchantIdentifier : 'merchant.test.com' ,
838+ } ,
839+ } ,
840+ } ;
841+
842+ const expectedError = new Error (
843+ `'wallets.applePay.contactFields' contains unexpected values. Expected "email, phone", received "invalid"` ,
844+ ) ;
845+
846+ await expect (
847+ instance . configureAcceleratedCheckouts ( invalidConfig as any ) ,
848+ ) . resolves . toBe ( false ) ;
849+ expect ( console . error ) . toHaveBeenCalledWith (
850+ '[ShopifyCheckoutSheetKit] Failed to configure accelerated checkouts with' ,
851+ expectedError ,
852+ ) ;
808853 } ) ;
809854
810855 it ( 'does not throw when Apple Pay wallet is not configured' , async ( ) => {
0 commit comments