mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-03 09:38:54 +00:00
Show verified store trials in the native cloud purchase flow [skip ci]
This commit is contained in:
@@ -84,15 +84,22 @@ describe('native client', () => {
|
||||
expect(await fakeIapClient.isSandbox()).toBe(true);
|
||||
});
|
||||
|
||||
it('maps the store price strings by product', async () => {
|
||||
shell.storeProducts.mockResolvedValue({ products: [{ id: 'cloud.plus.monthly', displayPrice: '9,99 €' }] });
|
||||
const prices = await nativeIapClient.prices(['cloud.plus.monthly', 'cloud.pro.monthly']);
|
||||
expect(shell.storeProducts).toHaveBeenCalledWith({ ids: ['cloud.plus.monthly', 'cloud.pro.monthly'] });
|
||||
expect(prices.get('cloud.plus.monthly')).toBe('9,99 €');
|
||||
expect(prices.has('cloud.pro.monthly')).toBe(false);
|
||||
it('maps the regular price and explicitly confirmed trial by product', async () => {
|
||||
shell.storeProducts.mockResolvedValue({
|
||||
products: [
|
||||
{ id: 'cloud.plus.monthly', displayPrice: '9,99 €', freeTrial: true },
|
||||
{ id: 'cloud.start.monthly', displayPrice: '4,99 €' },
|
||||
],
|
||||
});
|
||||
const ids = ['cloud.plus.monthly', 'cloud.start.monthly', 'cloud.plus.yearly'];
|
||||
const products = await nativeIapClient.products(ids);
|
||||
expect(shell.storeProducts).toHaveBeenCalledWith({ ids });
|
||||
expect(products.get('cloud.plus.monthly')).toEqual({ displayPrice: '9,99 €', freeTrial: true });
|
||||
expect(products.get('cloud.start.monthly')).toEqual({ displayPrice: '4,99 €', freeTrial: false });
|
||||
expect(products.has('cloud.plus.yearly')).toBe(false);
|
||||
|
||||
shell.storeProducts.mockRejectedValue(new Error('down'));
|
||||
expect((await nativeIapClient.prices(['cloud.plus.monthly'])).size).toBe(0);
|
||||
expect((await nativeIapClient.products(['cloud.plus.monthly'])).size).toBe(0);
|
||||
});
|
||||
|
||||
it('turns a bought transaction into a receipt', async () => {
|
||||
@@ -124,6 +131,15 @@ describe('native client', () => {
|
||||
expect(await nativeIapClient.held()).toBe(false);
|
||||
});
|
||||
|
||||
it('asks the store to preserve an advertised trial and reports a changed offer without retrying as paid', async () => {
|
||||
shell.storePurchase.mockResolvedValue({ kind: 'offer-changed' });
|
||||
expect(await nativeIapClient.purchase('cloud.plus.monthly', '9,99 €')).toEqual({ kind: 'offer-changed' });
|
||||
expect(shell.storePurchase).toHaveBeenCalledExactlyOnceWith({
|
||||
productId: 'cloud.plus.monthly',
|
||||
trialRenewalPrice: '9,99 €',
|
||||
});
|
||||
});
|
||||
|
||||
it('a build without storeHeld counts as holding nothing; the purchase still guards', async () => {
|
||||
shell.storeHeld.mockRejectedValue(new Error('not implemented'));
|
||||
expect(await nativeIapClient.held()).toBe(false);
|
||||
|
||||
Reference in New Issue
Block a user