@@ -58,6 +58,7 @@ describe('GooglePay', () => {
58
58
describe ( 'onClick()' , ( ) => {
59
59
test ( 'should not call "initiatePayment" if the onClick reject() is called' , async ( ) => {
60
60
const googlepay = new GooglePay ( global . core , {
61
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
61
62
onClick ( resolve , reject ) {
62
63
reject ( ) ;
63
64
}
@@ -73,6 +74,7 @@ describe('GooglePay', () => {
73
74
74
75
test ( 'should call "initiatePayment" if the onClick resolve() is called' , async ( ) => {
75
76
const googlepay = new GooglePay ( global . core , {
77
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
76
78
onClick ( resolve ) {
77
79
resolve ( ) ;
78
80
}
@@ -89,16 +91,27 @@ describe('GooglePay', () => {
89
91
90
92
describe ( 'isExpress flag' , ( ) => {
91
93
test ( 'should add subtype: express when isExpress is configured' , ( ) => {
92
- const googlepay = new GooglePay ( global . core , { isExpress : true } ) ;
94
+ const googlepay = new GooglePay ( global . core , {
95
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
96
+ isExpress : true
97
+ } ) ;
93
98
expect ( googlepay . data . paymentMethod ) . toHaveProperty ( 'subtype' , 'express' ) ;
94
99
} ) ;
95
100
test ( 'should not add subtype: express when isExpress is omitted' , ( ) => {
96
- const googlepay = new GooglePay ( global . core ) ;
101
+ const googlepay = new GooglePay ( global . core , {
102
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' }
103
+ } ) ;
97
104
expect ( googlepay . data . paymentMethod ) . not . toHaveProperty ( 'subtype' , 'express' ) ;
98
105
} ) ;
99
106
100
107
test ( 'should throw error when express callbacks are passed but isExpress flag is not set' , ( ) => {
101
- expect ( ( ) => new GooglePay ( global . core , { paymentDataCallbacks : { onPaymentDataChanged : jest . fn ( ) } } ) ) . toThrow ( ) ;
108
+ expect (
109
+ ( ) =>
110
+ new GooglePay ( global . core , {
111
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
112
+ paymentDataCallbacks : { onPaymentDataChanged : jest . fn ( ) }
113
+ } )
114
+ ) . toThrow ( ) ;
102
115
} ) ;
103
116
} ) ;
104
117
@@ -112,6 +125,7 @@ describe('GooglePay', () => {
112
125
const onPaymentCompletedMock = jest . fn ( ) ;
113
126
114
127
const gpay = new GooglePay ( global . core , {
128
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
115
129
onSubmit : onSubmitMock ,
116
130
onPaymentCompleted : onPaymentCompletedMock
117
131
} ) ;
@@ -176,6 +190,7 @@ describe('GooglePay', () => {
176
190
} ) ;
177
191
178
192
new GooglePay ( global . core , {
193
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
179
194
onSubmit : onSubmitMock
180
195
} ) ;
181
196
@@ -214,6 +229,7 @@ describe('GooglePay', () => {
214
229
const onPaymentFailedMock = jest . fn ( ) ;
215
230
216
231
const gpay = new GooglePay ( global . core , {
232
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
217
233
i18n : global . i18n ,
218
234
onSubmit : onSubmitMock ,
219
235
onPaymentFailed : onPaymentFailedMock
@@ -256,6 +272,7 @@ describe('GooglePay', () => {
256
272
const onPaymentFailedMock = jest . fn ( ) ;
257
273
258
274
const gpay = new GooglePay ( global . core , {
275
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
259
276
i18n : global . i18n ,
260
277
onSubmit : onSubmitMock ,
261
278
onPaymentFailed : onPaymentFailedMock
@@ -338,7 +355,10 @@ describe('GooglePay', () => {
338
355
339
356
test ( 'should provide GooglePay auth event and formatted data' , ( ) => {
340
357
const onAuthorizedMock = jest . fn ( ) ;
341
- new GooglePay ( global . core , { onAuthorized : onAuthorizedMock } ) ;
358
+ new GooglePay ( global . core , {
359
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
360
+ onAuthorized : onAuthorizedMock
361
+ } ) ;
342
362
343
363
// @ts -ignore GooglePayService is mocked
344
364
const onPaymentAuthorized = GooglePayService . mock . calls [ 0 ] [ 1 ] . onPaymentAuthorized ;
@@ -354,6 +374,7 @@ describe('GooglePay', () => {
354
374
const onPaymentFailedMock = jest . fn ( ) ;
355
375
356
376
new GooglePay ( global . core , {
377
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
357
378
i18n : global . i18n ,
358
379
onAuthorized : onAuthorizedMock ,
359
380
onPaymentFailed : onPaymentFailedMock
@@ -383,6 +404,7 @@ describe('GooglePay', () => {
383
404
const onPaymentCompletedMock = jest . fn ( ) ;
384
405
385
406
const gpay = new GooglePay ( global . core , {
407
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
386
408
i18n : global . i18n ,
387
409
onAuthorized : onAuthorizedMock ,
388
410
onPaymentCompleted : onPaymentCompletedMock
@@ -399,7 +421,10 @@ describe('GooglePay', () => {
399
421
} ) ;
400
422
401
423
test ( 'should make the payments call if onAuthorized is not provided' , async ( ) => {
402
- const gpay = new GooglePay ( global . core , { i18n : global . i18n } ) ;
424
+ const gpay = new GooglePay ( global . core , {
425
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
426
+ i18n : global . i18n
427
+ } ) ;
403
428
404
429
const paymentCall = jest . spyOn ( gpay as any , 'makePaymentsCall' ) ;
405
430
@@ -414,7 +439,7 @@ describe('GooglePay', () => {
414
439
415
440
describe ( 'isAvailable()' , ( ) => {
416
441
test ( 'should resolve if GooglePay is available' , async ( ) => {
417
- const gpay = new GooglePay ( global . core ) ;
442
+ const gpay = new GooglePay ( global . core , { configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } } ) ;
418
443
gpay . isReadyToPay = jest . fn ( ( ) => {
419
444
return Promise . resolve ( { result : true } ) ;
420
445
} ) ;
@@ -423,7 +448,7 @@ describe('GooglePay', () => {
423
448
} ) ;
424
449
425
450
test ( 'should reject if is not available' , async ( ) => {
426
- const gpay = new GooglePay ( global . core ) ;
451
+ const gpay = new GooglePay ( global . core , { configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } } ) ;
427
452
gpay . isReadyToPay = jest . fn ( ( ) => {
428
453
return Promise . resolve ( { result : false } ) ;
429
454
} ) ;
@@ -432,7 +457,7 @@ describe('GooglePay', () => {
432
457
} ) ;
433
458
434
459
test ( 'should reject if "paymentMethodPresent" is false' , async ( ) => {
435
- const gpay = new GooglePay ( global . core ) ;
460
+ const gpay = new GooglePay ( global . core , { configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } } ) ;
436
461
gpay . isReadyToPay = jest . fn ( ( ) => {
437
462
return Promise . resolve ( { result : true , paymentMethodPresent : false } ) ;
438
463
} ) ;
@@ -442,19 +467,15 @@ describe('GooglePay', () => {
442
467
} ) ;
443
468
444
469
describe ( 'Process CA based configuration data' , ( ) => {
445
- test ( 'Retrieves default merchantId' , ( ) => {
446
- const gpay = new GooglePay ( global . core ) ;
447
- expect ( gpay . props . configuration . merchantId ) . toEqual ( '' ) ;
448
- } ) ;
449
-
450
470
test ( 'Retrieves merchantId from configuration' , ( ) => {
451
471
const gpay = new GooglePay ( global . core , { configuration : { merchantId : 'abcdef' , gatewayMerchantId : 'TestMerchant' } } ) ;
452
472
expect ( gpay . props . configuration . merchantId ) . toEqual ( 'abcdef' ) ;
453
473
} ) ;
454
474
455
- test ( 'Retrieves merchantId from configuration' , ( ) => {
475
+ test ( 'Retrieves merchantOrigin from configuration' , ( ) => {
456
476
const gpay = new GooglePay ( global . core , {
457
477
configuration : {
478
+ merchantId : 'abcdef' ,
458
479
gatewayMerchantId : 'TestMerchant' ,
459
480
merchantOrigin : 'example.com'
460
481
}
@@ -476,6 +497,7 @@ describe('GooglePay', () => {
476
497
console . log = jest . fn ( ( ) => { } ) ;
477
498
478
499
gpay = new GooglePay ( global . core , {
500
+ configuration : { merchantId : 'merchant-id' , gatewayMerchantId : 'gateway-id' } ,
479
501
type : 'googlepay' ,
480
502
isInstantPayment : true ,
481
503
modules : {
0 commit comments