mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Updated tests for tier label
This commit is contained in:
parent
bf12fb935d
commit
f8776b4fef
2 changed files with 9 additions and 7 deletions
|
@ -46,23 +46,25 @@ const customSetup = (overrides) => {
|
||||||
|
|
||||||
describe('Account Plan Page', () => {
|
describe('Account Plan Page', () => {
|
||||||
test('renders', () => {
|
test('renders', () => {
|
||||||
const {monthlyCheckboxEl, yearlyCheckboxEl, chooseBtns} = setup();
|
const {monthlyCheckboxEl, yearlyCheckboxEl, queryAllByRole} = setup();
|
||||||
|
const continueBtn = queryAllByRole('button', {name: 'Continue'});
|
||||||
expect(monthlyCheckboxEl).toBeInTheDocument();
|
expect(monthlyCheckboxEl).toBeInTheDocument();
|
||||||
expect(yearlyCheckboxEl).toBeInTheDocument();
|
expect(yearlyCheckboxEl).toBeInTheDocument();
|
||||||
expect(chooseBtns).toHaveLength(1);
|
expect(continueBtn).toHaveLength(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can choose plan and continue', async () => {
|
test('can choose plan and continue', async () => {
|
||||||
const siteData = getSiteData({
|
const siteData = getSiteData({
|
||||||
products: getProductsData({numOfProducts: 1})
|
products: getProductsData({numOfProducts: 1})
|
||||||
});
|
});
|
||||||
const {mockOnActionFn, monthlyCheckboxEl, yearlyCheckboxEl, chooseBtns} = setup({site: siteData});
|
const {mockOnActionFn, monthlyCheckboxEl, yearlyCheckboxEl, queryAllByRole} = setup({site: siteData});
|
||||||
|
const continueBtn = queryAllByRole('button', {name: 'Continue'});
|
||||||
|
|
||||||
fireEvent.click(monthlyCheckboxEl);
|
fireEvent.click(monthlyCheckboxEl);
|
||||||
expect(monthlyCheckboxEl.className).toEqual('gh-portal-btn active');
|
expect(monthlyCheckboxEl.className).toEqual('gh-portal-btn active');
|
||||||
fireEvent.click(yearlyCheckboxEl);
|
fireEvent.click(yearlyCheckboxEl);
|
||||||
expect(yearlyCheckboxEl.className).toEqual('gh-portal-btn active');
|
expect(yearlyCheckboxEl.className).toEqual('gh-portal-btn active');
|
||||||
fireEvent.click(chooseBtns[0]);
|
fireEvent.click(continueBtn[0]);
|
||||||
expect(mockOnActionFn).toHaveBeenCalledWith('checkoutPlan', {plan: siteData.products[0].yearlyPrice.id});
|
expect(mockOnActionFn).toHaveBeenCalledWith('checkoutPlan', {plan: siteData.products[0].yearlyPrice.id});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -207,7 +207,7 @@ describe('Logged-in free member', () => {
|
||||||
// added fake timeout for react state delay in setting plan
|
// added fake timeout for react state delay in setting plan
|
||||||
await new Promise(r => setTimeout(r, 10));
|
await new Promise(r => setTimeout(r, 10));
|
||||||
|
|
||||||
const submitButton = within(popupIframeDocument).queryByRole('button', {name: 'Choose'});
|
const submitButton = within(popupIframeDocument).queryByRole('button', {name: 'Continue'});
|
||||||
|
|
||||||
fireEvent.click(submitButton);
|
fireEvent.click(submitButton);
|
||||||
expect(ghostApi.member.checkoutPlan).toHaveBeenLastCalledWith({
|
expect(ghostApi.member.checkoutPlan).toHaveBeenLastCalledWith({
|
||||||
|
@ -244,7 +244,7 @@ describe('Logged-in free member', () => {
|
||||||
// added fake timeout for react state delay in setting plan
|
// added fake timeout for react state delay in setting plan
|
||||||
await new Promise(r => setTimeout(r, 10));
|
await new Promise(r => setTimeout(r, 10));
|
||||||
|
|
||||||
const submitButton = within(popupIframeDocument).queryByRole('button', {name: 'Choose'});
|
const submitButton = within(popupIframeDocument).queryByRole('button', {name: 'Continue'});
|
||||||
|
|
||||||
fireEvent.click(submitButton);
|
fireEvent.click(submitButton);
|
||||||
expect(ghostApi.member.checkoutPlan).toHaveBeenLastCalledWith({
|
expect(ghostApi.member.checkoutPlan).toHaveBeenLastCalledWith({
|
||||||
|
|
Loading…
Add table
Reference in a new issue