@@ -558,6 +558,38 @@ describe("Checkout", (): void => {
558
558
expect ( sessionsResponse . expiresAt . getFullYear ( ) ) . toBeGreaterThan ( 0 ) ;
559
559
} ) ;
560
560
561
+ test ( "should create a session instantiating an object" , async ( ) : Promise < void > => {
562
+
563
+ const expectedPayload = {
564
+ merchantAccount : "myMerchantAccount" ,
565
+ reference : "myReference" ,
566
+ returnUrl : "https://your-company.com/..." ,
567
+ countryCode : "NL" ,
568
+ amount : {
569
+ currency : "USD" ,
570
+ value : 1000 ,
571
+ } ,
572
+ } ;
573
+ scope . post ( "/sessions" , ( body ) => {
574
+ expect ( body ) . toEqual ( expectedPayload ) ;
575
+ return true ; // return true to indicate that the body matches the expected payload
576
+ } ) . reply ( 200 , sessionsSuccess ) ;
577
+
578
+ const sessionsRequest : checkout . CreateCheckoutSessionRequest = new checkout . CreateCheckoutSessionRequest ( ) ;
579
+ sessionsRequest . merchantAccount = "myMerchantAccount" ;
580
+ sessionsRequest . reference = "myReference" ;
581
+ sessionsRequest . returnUrl = "https://your-company.com/..." ;
582
+ sessionsRequest . countryCode = "NL" ;
583
+ sessionsRequest . amount = new checkout . Amount ( ) ;
584
+ sessionsRequest . amount . currency = "USD" ;
585
+ sessionsRequest . amount . value = 1000 ;
586
+
587
+ const sessionsResponse : checkout . CreateCheckoutSessionResponse = await checkoutService . PaymentsApi . sessions ( sessionsRequest ) ;
588
+ expect ( sessionsResponse . sessionData ) . toBeTruthy ( ) ;
589
+ expect ( sessionsResponse . expiresAt ) . toBeInstanceOf ( Date ) ;
590
+ expect ( sessionsResponse . expiresAt . getFullYear ( ) ) . toBeGreaterThan ( 0 ) ;
591
+ } ) ;
592
+
561
593
test ( "should create a session with installmentOptions." , async ( ) : Promise < void > => {
562
594
scope . post ( "/sessions" )
563
595
. reply ( 200 , sessionsSuccess ) ;
0 commit comments