@@ -558,6 +558,38 @@ describe("Checkout", (): void => {
558558 expect ( sessionsResponse . expiresAt . getFullYear ( ) ) . toBeGreaterThan ( 0 ) ;
559559 } ) ;
560560
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+
561593 test ( "should create a session with installmentOptions." , async ( ) : Promise < void > => {
562594 scope . post ( "/sessions" )
563595 . reply ( 200 , sessionsSuccess ) ;
0 commit comments