@@ -68,12 +68,48 @@ describe("three domain secure component - isEligible method", () => {
68
68
expect ( eligibility ) . toEqual ( false ) ;
69
69
} ) ;
70
70
71
- test . todo ( "create payload with correctly parameters" , async ( ) => {
72
- const threeDomainSecureClient = createThreeDomainSecureComponent ( ) ;
71
+ test ( "should assign correct URL to authenticationURL" , async ( ) => {
72
+ const threeDomainSecureClient = createThreeDomainSecureComponent ( {
73
+ request : ( ) =>
74
+ Promise . resolve ( {
75
+ ...defaultEligibilityResponse ,
76
+ links : [
77
+ { href : "https://not-payer-action.com" , rel : "not-payer-action" } ,
78
+ ...defaultEligibilityResponse . links ,
79
+ ] ,
80
+ } ) ,
81
+ } ) ;
82
+ await threeDomainSecureClient . isEligible ( defaultMerchantPayload ) ;
83
+ expect ( threeDomainSecureClient . authenticationURL ) . toEqual (
84
+ "https://testurl.com"
85
+ ) ;
86
+ } ) ;
87
+
88
+ test ( "create payload with correctly parameters" , async ( ) => {
73
89
const mockedRequest = mockEligibilityRequest ( ) ;
90
+ const threeDomainSecureClient = createThreeDomainSecureComponent ( {
91
+ request : mockedRequest ,
92
+ } ) ;
93
+
74
94
await threeDomainSecureClient . isEligible ( defaultMerchantPayload ) ;
75
95
76
- expect ( mockedRequest ) . toHaveBeenCalledWith ( ) ;
96
+ expect ( mockedRequest ) . toHaveBeenCalledWith (
97
+ expect . objectContaining ( {
98
+ data : expect . objectContaining ( {
99
+ intent : "THREE_DS_VERIFICATION" ,
100
+ payment_source : expect . objectContaining ( {
101
+ card : expect . objectContaining ( {
102
+ single_use_token : defaultMerchantPayload . nonce ,
103
+ verification_method : "SCA_WHEN_REQUIRED" ,
104
+ } ) ,
105
+ } ) ,
106
+ amount : expect . objectContaining ( {
107
+ currency_code : defaultMerchantPayload . currency ,
108
+ value : defaultMerchantPayload . amount ,
109
+ } ) ,
110
+ } ) ,
111
+ } )
112
+ ) ;
77
113
} ) ;
78
114
79
115
test ( "catch errors from the API" , async ( ) => {
0 commit comments