@@ -146,6 +146,24 @@ describe("Purchases", () => {
146
146
expect ( offerings ) . toEqual ( offeringsStub ) ;
147
147
} )
148
148
149
+ it ( "get current offerings for placement works" , async ( ) => {
150
+ NativeModules . RNPurchases . getCurrentOfferingForPlacement . mockResolvedValueOnce ( currentOfferingForPlacementStub ) ;
151
+
152
+ const offering = await Purchases . getCurrentOfferingForPlacement ( "onboarding" )
153
+
154
+ expect ( NativeModules . RNPurchases . getCurrentOfferingForPlacement ) . toBeCalledWith ( "onboarding" )
155
+ expect ( offering ) . toEqual ( currentOfferingForPlacementStub ) ;
156
+ } )
157
+
158
+ it ( "sync attributes and offerings if needed works" , async ( ) => {
159
+ NativeModules . RNPurchases . syncAttributesAndOfferingsIfNeeded . mockResolvedValueOnce ( offeringsStub ) ;
160
+
161
+ const offerings = await Purchases . syncAttributesAndOfferingsIfNeeded ( )
162
+
163
+ expect ( NativeModules . RNPurchases . syncAttributesAndOfferingsIfNeeded ) . toBeCalledTimes ( 1 ) ;
164
+ expect ( offerings ) . toEqual ( offeringsStub ) ;
165
+ } )
166
+
149
167
it ( "getProducts works and gets subs by default" , async ( ) => {
150
168
NativeModules . RNPurchases . getProductInfo . mockResolvedValueOnce ( productsStub ) ;
151
169
@@ -215,14 +233,14 @@ describe("Purchases", () => {
215
233
currency_code : "USD" ,
216
234
introPrice : null
217
235
} ,
218
- offeringIdentifier : "offering" ,
236
+ presentedOfferingContext : { offeringIdentifier : "offering" } ,
219
237
} ,
220
238
{
221
239
oldSKU : "viejo" ,
222
240
prorationMode : Purchases . PRORATION_MODE . IMMEDIATE_AND_CHARGE_FULL_PRICE
223
241
} ,
224
242
) ;
225
- expect ( NativeModules . RNPurchases . purchasePackage ) . toBeCalledWith ( "$rc_onemonth" , "offering" , {
243
+ expect ( NativeModules . RNPurchases . purchasePackage ) . toBeCalledWith ( "$rc_onemonth" , { offeringIdentifier : "offering" } , {
226
244
oldSKU : "viejo" ,
227
245
prorationMode : Purchases . PRORATION_MODE . IMMEDIATE_AND_CHARGE_FULL_PRICE
228
246
} , null , null ) ;
@@ -237,12 +255,12 @@ describe("Purchases", () => {
237
255
238
256
const aProduct = {
239
257
...productStub ,
240
- presentedOfferingIdentifier : "the-offerings"
258
+ presentedOfferingContext : { offeringIdentifier : "the-offerings" }
241
259
}
242
260
243
261
await Purchases . purchaseStoreProduct ( aProduct )
244
262
245
- expect ( NativeModules . RNPurchases . purchaseProduct ) . toBeCalledWith ( aProduct . identifier , undefined , Purchases . PRODUCT_CATEGORY . SUBSCRIPTION , null , null , "the-offerings" ) ;
263
+ expect ( NativeModules . RNPurchases . purchaseProduct ) . toBeCalledWith ( aProduct . identifier , undefined , Purchases . PRODUCT_CATEGORY . SUBSCRIPTION , null , null , { offeringIdentifier : "the-offerings" } ) ;
246
264
expect ( NativeModules . RNPurchases . purchaseProduct ) . toBeCalledTimes ( 1 ) ;
247
265
} ) ;
248
266
@@ -267,10 +285,10 @@ describe("Purchases", () => {
267
285
currencyCode : "USD" ,
268
286
introPrice : null
269
287
} ,
270
- offeringIdentifier : "offering" ,
288
+ presentedOfferingContext : { offeringIdentifier : "offering" } ,
271
289
} ) ;
272
290
273
- expect ( NativeModules . RNPurchases . purchasePackage ) . toBeCalledWith ( "$rc_onemonth" , "offering" , undefined , null , null ) ;
291
+ expect ( NativeModules . RNPurchases . purchasePackage ) . toBeCalledWith ( "$rc_onemonth" , { offeringIdentifier : "offering" } , undefined , null , null ) ;
274
292
expect ( NativeModules . RNPurchases . purchasePackage ) . toBeCalledTimes ( 1 ) ;
275
293
276
294
await Purchases . purchasePackage (
@@ -286,15 +304,15 @@ describe("Purchases", () => {
286
304
currency_code : "USD" ,
287
305
introPrice : null
288
306
} ,
289
- offeringIdentifier : "offering" ,
307
+ presentedOfferingContext : { offeringIdentifier : "offering" } ,
290
308
} ,
291
309
{
292
310
oldSKU : "viejo" ,
293
311
prorationMode : Purchases . PRORATION_MODE . IMMEDIATE_AND_CHARGE_FULL_PRICE
294
312
} ,
295
313
) ;
296
314
297
- expect ( NativeModules . RNPurchases . purchasePackage ) . toBeCalledWith ( "$rc_onemonth" , "offering" , {
315
+ expect ( NativeModules . RNPurchases . purchasePackage ) . toBeCalledWith ( "$rc_onemonth" , { offeringIdentifier : "offering" } , {
298
316
oldSKU : "viejo" ,
299
317
prorationMode : Purchases . PRORATION_MODE . IMMEDIATE_AND_CHARGE_FULL_PRICE
300
318
} , null , null ) ;
@@ -312,14 +330,14 @@ describe("Purchases", () => {
312
330
currency_code : "USD" ,
313
331
introPrice : null
314
332
} ,
315
- offeringIdentifier : "offering" ,
333
+ presentedOfferingContext : { offeringIdentifier : "offering" } ,
316
334
} ,
317
335
{
318
336
oldProductIdentifier : "viejo" ,
319
337
prorationMode : Purchases . PRORATION_MODE . IMMEDIATE_AND_CHARGE_FULL_PRICE
320
338
} ,
321
339
) ;
322
- expect ( NativeModules . RNPurchases . purchasePackage ) . toBeCalledWith ( "$rc_onemonth" , "offering" , {
340
+ expect ( NativeModules . RNPurchases . purchasePackage ) . toBeCalledWith ( "$rc_onemonth" , { offeringIdentifier : "offering" } , {
323
341
oldProductIdentifier : "viejo" ,
324
342
prorationMode : Purchases . PRORATION_MODE . IMMEDIATE_AND_CHARGE_FULL_PRICE
325
343
} , null , null ) ;
@@ -367,7 +385,7 @@ describe("Purchases", () => {
367
385
presentedOfferingIdentifier : null
368
386
} ) ;
369
387
370
- expect ( NativeModules . RNPurchases . purchaseSubscriptionOption ) . toBeCalledWith ( "gold" , "monthly" , undefined , null , null , null ) ;
388
+ expect ( NativeModules . RNPurchases . purchaseSubscriptionOption ) . toBeCalledWith ( "gold" , "monthly" , undefined , null , null , undefined ) ;
371
389
expect ( NativeModules . RNPurchases . purchaseSubscriptionOption ) . toBeCalledTimes ( 1 ) ;
372
390
373
391
await Purchases . purchaseSubscriptionOption (
@@ -383,7 +401,7 @@ describe("Purchases", () => {
383
401
fullPricePhase : phase ,
384
402
freePhase : null ,
385
403
introPhase : null ,
386
- presentedOfferingIdentifier : "offering"
404
+ presentedOfferingContext : { offeringIdentifier : "offering" } ,
387
405
} ,
388
406
{
389
407
oldProductIdentifier : "viejo" ,
@@ -395,7 +413,7 @@ describe("Purchases", () => {
395
413
expect ( NativeModules . RNPurchases . purchaseSubscriptionOption ) . toBeCalledWith ( "gold" , "monthly" , {
396
414
oldProductIdentifier : "viejo" ,
397
415
prorationMode : Purchases . PRORATION_MODE . IMMEDIATE_AND_CHARGE_FULL_PRICE
398
- } , null , { isPersonalizedPrice : true } , "offering" ) ;
416
+ } , null , { isPersonalizedPrice : true } , { offeringIdentifier : "offering" } ) ;
399
417
expect ( NativeModules . RNPurchases . purchaseSubscriptionOption ) . toBeCalledTimes ( 2 ) ;
400
418
} ) ;
401
419
@@ -794,7 +812,7 @@ describe("Purchases", () => {
794
812
795
813
await Purchases . purchaseDiscountedProduct ( aProduct , promotionalOfferStub )
796
814
797
- expect ( NativeModules . RNPurchases . purchaseProduct ) . toBeCalledWith ( aProduct . identifier , null , null , promotionalOfferStub . timestamp . toString ( ) , null , null ) ;
815
+ expect ( NativeModules . RNPurchases . purchaseProduct ) . toBeCalledWith ( aProduct . identifier , null , null , promotionalOfferStub . timestamp . toString ( ) , null , undefined ) ;
798
816
expect ( NativeModules . RNPurchases . purchaseProduct ) . toBeCalledTimes ( 1 ) ;
799
817
} ) ;
800
818
0 commit comments