@@ -13,6 +13,7 @@ import { InAppOwnershipType } from "../../models/InAppOwnershipType";
1313import { RevocationReason } from "../../models/RevocationReason" ;
1414import { TransactionReason } from "../../models/TransactionReason" ;
1515import { Type } from "../../models/Type" ;
16+ import { ConsumptionRequestReason } from "../../models/ConsumptionRequestReason" ;
1617
1718
1819describe ( 'Testing decoding of signed data' , ( ) => {
@@ -102,6 +103,29 @@ describe('Testing decoding of signed data', () => {
102103 expect ( "signed_transaction_info_value" ) . toBe ( notification . data ! . signedTransactionInfo )
103104 expect ( "signed_renewal_info_value" ) . toBe ( notification . data ! . signedRenewalInfo )
104105 expect ( Status . ACTIVE ) . toBe ( notification . data ! . status )
106+ expect ( notification . data ! . consumptionRequestReason ) . toBeFalsy ( )
107+ } )
108+ it ( 'should decode a signed CONSUMPTION_REQUEST notification' , async ( ) => {
109+ const signedNotification = createSignedDataFromJson ( "tests/resources/models/signedNotification.json" )
110+
111+ const notification = await getDefaultSignedPayloadVerifier ( ) . verifyAndDecodeNotification ( signedNotification )
112+
113+ expect ( NotificationTypeV2 . CONSUMPTION_REQUEST ) . toBe ( notification . notificationType )
114+ expect ( notification . subtype ) . toBeFalsy ( )
115+ expect ( "002e14d5-51f5-4503-b5a8-c3a1af68eb20" ) . toBe ( notification . notificationUUID )
116+ expect ( "2.0" ) . toBe ( notification . version )
117+ expect ( 1698148900000 ) . toBe ( notification . signedDate )
118+ expect ( notification . data ) . toBeTruthy ( )
119+ expect ( notification . summary ) . toBeFalsy ( )
120+ expect ( notification . externalPurchaseToken ) . toBeFalsy ( )
121+ expect ( Environment . LOCAL_TESTING ) . toBe ( notification . data ! . environment )
122+ expect ( 41234 ) . toBe ( notification . data ! . appAppleId )
123+ expect ( "com.example" ) . toBe ( notification . data ! . bundleId )
124+ expect ( "1.2.3" ) . toBe ( notification . data ! . bundleVersion )
125+ expect ( "signed_transaction_info_value" ) . toBe ( notification . data ! . signedTransactionInfo )
126+ expect ( "signed_renewal_info_value" ) . toBe ( notification . data ! . signedRenewalInfo )
127+ expect ( Status . ACTIVE ) . toBe ( notification . data ! . status )
128+ expect ( ConsumptionRequestReason . UNINTENDED_PURCHASE ) . toBe ( notification . data ! . consumptionRequestReason )
105129 } )
106130 it ( 'should decode a signed summary notification' , async ( ) => {
107131 const signedNotification = createSignedDataFromJson ( "tests/resources/models/signedSummaryNotification.json" )
0 commit comments