1
1
import nock , { Interceptor } from "nock" ;
2
2
import Client from "../client" ;
3
+ import { createClient } from "../__mocks__/base" ;
3
4
import { BinLookupAPI } from "../services" ;
4
5
import ApiException from "../services/exception/apiException" ;
5
6
import HttpClientException from "../httpClient/httpClientException" ;
7
+ import { binlookup } from "../typings" ;
8
+ import { ApiConstants } from "../constants/apiConstants" ;
6
9
7
10
beforeEach ( ( ) : void => {
8
11
nock . cleanAll ( ) ;
@@ -60,4 +63,41 @@ describe("HTTP Client", function (): void {
60
63
return { errorType, errorMessageContains : contains , errorMessageEquals : equals } ;
61
64
} ) ;
62
65
} ) ;
63
- } ) ;
66
+
67
+ test ( "should succeed on get 3ds availability" , async function ( ) : Promise < void > {
68
+
69
+ const threeDSAvailabilitySuccessResponse = {
70
+ binDetails : {
71
+ issuerCountry : "NL"
72
+ } ,
73
+ threeDS1Supported : true ,
74
+ threeDS2CardRangeDetails : [ ] ,
75
+ threeDS2supported : false
76
+ } ;
77
+
78
+ const client = createClient ( ) ;
79
+ const binLookupService = new BinLookupAPI ( client ) ;
80
+ const scope = nock ( "https://pal-test.adyen.com/pal/servlet/BinLookup/v54" , {
81
+ reqheaders : {
82
+ 'Content-Type' : ApiConstants . APPLICATION_JSON_TYPE ,
83
+ "foo" : "bar"
84
+ } ,
85
+ } )
86
+ . get ( '/' )
87
+ . reply ( 200 )
88
+
89
+ const threeDSAvailabilityRequest : binlookup . ThreeDSAvailabilityRequest = {
90
+ merchantAccount : process . env . ADYEN_MERCHANT ! ,
91
+ brands : [ "randomBrand" ] ,
92
+ cardNumber : "4111111111111111"
93
+ } ;
94
+
95
+ scope . post ( "/get3dsAvailability" )
96
+ . reply ( 200 , threeDSAvailabilitySuccessResponse ) ;
97
+
98
+ const requestOptions = { headers : { foo : "bar" } }
99
+ const response = await binLookupService . get3dsAvailability ( threeDSAvailabilityRequest , requestOptions ) ;
100
+ expect ( response ) . toEqual < binlookup . ThreeDSAvailabilityResponse > ( threeDSAvailabilitySuccessResponse ) ;
101
+ } ) ;
102
+
103
+ } ) ;
0 commit comments