@@ -801,4 +801,75 @@ describe('The api client ', () => {
801801
802802 await client . deleteDefaultMessage ( "com.example.product" , "en-US" )
803803 } )
804+
805+ it ( 'calls getAppTransactionInfo' , async ( ) => {
806+ const client = getClientWithBody ( "tests/resources/models/appTransactionInfoResponse.json" , ( path : string , parsedQueryParameters : URLSearchParams , method : string , requestBody : string | Buffer | undefined , headers : { [ key : string ] : string ; } ) => {
807+ expect ( "GET" ) . toBe ( method )
808+ expect ( "/inApps/v1/transactions/appTransactions/1234" ) . toBe ( path )
809+ expect ( parsedQueryParameters . entries . length ) . toBe ( 0 )
810+ expect ( requestBody ) . toBeUndefined ( )
811+ } ) ;
812+
813+ const appTransactionInfoResponse = await client . getAppTransactionInfo ( "1234" ) ;
814+
815+ expect ( appTransactionInfoResponse ) . toBeTruthy ( )
816+ expect ( "signed_app_transaction_info_value" ) . toBe ( appTransactionInfoResponse . signedAppTransactionInfo )
817+ } )
818+
819+ it ( 'calls getAppTransactionInfo but receives invalid transaction id error' , async ( ) => {
820+ const client = getClientWithBody ( "tests/resources/models/invalidTransactionIdError.json" , ( path : string , parsedQueryParameters : URLSearchParams , method : string , requestBody : string | Buffer | undefined , headers : { [ key : string ] : string ; } ) => {
821+ expect ( "GET" ) . toBe ( method )
822+ expect ( "/inApps/v1/transactions/appTransactions/invalid_id" ) . toBe ( path )
823+ expect ( parsedQueryParameters . entries . length ) . toBe ( 0 )
824+ expect ( requestBody ) . toBeUndefined ( )
825+ } , 400 ) ;
826+
827+ try {
828+ const appTransactionInfoResponse = await client . getAppTransactionInfo ( "invalid_id" ) ;
829+ fail ( 'this test call is expected to throw' )
830+ } catch ( e ) {
831+ let error = e as APIException
832+ expect ( error . httpStatusCode ) . toBe ( 400 )
833+ expect ( error . apiError ) . toBe ( APIError . INVALID_TRANSACTION_ID )
834+ expect ( error . errorMessage ) . toBe ( "Invalid transaction id." )
835+ }
836+ } )
837+
838+ it ( 'calls getAppTransactionInfo but receives app transaction does not exist error' , async ( ) => {
839+ const client = getClientWithBody ( "tests/resources/models/appTransactionDoesNotExistError.json" , ( path : string , parsedQueryParameters : URLSearchParams , method : string , requestBody : string | Buffer | undefined , headers : { [ key : string ] : string ; } ) => {
840+ expect ( "GET" ) . toBe ( method )
841+ expect ( "/inApps/v1/transactions/appTransactions/5678" ) . toBe ( path )
842+ expect ( parsedQueryParameters . entries . length ) . toBe ( 0 )
843+ expect ( requestBody ) . toBeUndefined ( )
844+ } , 404 ) ;
845+
846+ try {
847+ const appTransactionInfoResponse = await client . getAppTransactionInfo ( "5678" ) ;
848+ fail ( 'this test call is expected to throw' )
849+ } catch ( e ) {
850+ let error = e as APIException
851+ expect ( error . httpStatusCode ) . toBe ( 404 )
852+ expect ( error . apiError ) . toBe ( APIError . APP_TRANSACTION_DOES_NOT_EXIST_ERROR )
853+ expect ( error . errorMessage ) . toBe ( "No AppTransaction exists for the customer." )
854+ }
855+ } )
856+
857+ it ( 'calls getAppTransactionInfo but receives transaction id not found error' , async ( ) => {
858+ const client = getClientWithBody ( "tests/resources/models/transactionIdNotFoundError.json" , ( path : string , parsedQueryParameters : URLSearchParams , method : string , requestBody : string | Buffer | undefined , headers : { [ key : string ] : string ; } ) => {
859+ expect ( "GET" ) . toBe ( method )
860+ expect ( "/inApps/v1/transactions/appTransactions/9999" ) . toBe ( path )
861+ expect ( parsedQueryParameters . entries . length ) . toBe ( 0 )
862+ expect ( requestBody ) . toBeUndefined ( )
863+ } , 404 ) ;
864+
865+ try {
866+ const appTransactionInfoResponse = await client . getAppTransactionInfo ( "9999" ) ;
867+ fail ( 'this test call is expected to throw' )
868+ } catch ( e ) {
869+ let error = e as APIException
870+ expect ( error . httpStatusCode ) . toBe ( 404 )
871+ expect ( error . apiError ) . toBe ( APIError . TRANSACTION_ID_NOT_FOUND )
872+ expect ( error . errorMessage ) . toBe ( "Transaction id not found." )
873+ }
874+ } )
804875} )
0 commit comments