This repository has been archived by the owner on Jun 26, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add in most of the wiring of the success modal * add in modal data * add in some tests * turn off subscription feature * add active product test and more test and fix some existing * remove wait ref
- Loading branch information
Showing
13 changed files
with
164 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { subscriptionDetails } from './subscription-details' | ||
|
||
const stampSubDetails = isSub => ({ | ||
user: { isSubscriber: isSub, products: [] }, | ||
products: [], | ||
getProduct: jest.fn(), | ||
buy: jest.fn(), | ||
}) | ||
|
||
test('subscriptionDetails should return error when no product is found', () => { | ||
const context = {} | ||
const subDetails = stampSubDetails() | ||
const callback = jest.fn() | ||
expect( | ||
subscriptionDetails(context, subDetails, callback).title | ||
).toMatch('Unable to subscribe') | ||
}) | ||
|
||
test('subscriptionDetails should return detail when there is a product', () => { | ||
const context = {} | ||
const subDetails = stampSubDetails() | ||
const callback = jest.fn() | ||
subDetails.getProduct.mockReturnValue({ | ||
sku: 'foo', | ||
prices: [ | ||
{ | ||
valueMicros: '990000', | ||
currencyCode: 'USD', | ||
regionCode: 'US', | ||
}, | ||
], | ||
localeData: [ | ||
{ | ||
title: 'Foo', | ||
description: 'Foo bar baz', | ||
languageCode: 'all', | ||
}, | ||
], | ||
}) | ||
expect( | ||
subscriptionDetails(context, subDetails, callback).button.children | ||
).toMatch('$0.99/mo') // correct pricing format | ||
}) | ||
|
||
test('subscriptionDetails should call buy when button is clicked', async () => { | ||
const context = { sku: 'foo', callback: jest.fn() } | ||
const subDetails = stampSubDetails() | ||
const changeModal = jest.fn() | ||
subDetails.getProduct.mockReturnValue({ | ||
sku: 'foo', | ||
prices: [ | ||
{ | ||
valueMicros: '990000', | ||
currencyCode: 'USD', | ||
regionCode: 'US', | ||
}, | ||
], | ||
localeData: [ | ||
{ | ||
title: 'Foo', | ||
description: 'Foo bar baz', | ||
languageCode: 'all', | ||
}, | ||
], | ||
}) | ||
subDetails.buy.mockResolvedValue(true) | ||
const options = { changeModal } | ||
const modal = subscriptionDetails(context, subDetails, options) | ||
await modal.button.onClick() | ||
expect(subDetails.buy).toBeCalledWith('foo') | ||
expect(context.callback).toBeCalled() | ||
expect(changeModal).toBeCalled() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export const subscriptionSuccess = (context, subDetails) => ({ | ||
title: 'Thanks for purchasing a subscription', | ||
description: [ | ||
'Your support is greatly appreciated!', | ||
'Please contact jacoblowe2.0@gmail.com with any comment or questions.', | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters