0
Fork 0
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:
Rishabh 2022-06-01 13:10:46 +05:30
parent bf12fb935d
commit f8776b4fef
2 changed files with 9 additions and 7 deletions

View file

@ -46,23 +46,25 @@ const customSetup = (overrides) => {
describe('Account Plan Page', () => {
test('renders', () => {
const {monthlyCheckboxEl, yearlyCheckboxEl, chooseBtns} = setup();
const {monthlyCheckboxEl, yearlyCheckboxEl, queryAllByRole} = setup();
const continueBtn = queryAllByRole('button', {name: 'Continue'});
expect(monthlyCheckboxEl).toBeInTheDocument();
expect(yearlyCheckboxEl).toBeInTheDocument();
expect(chooseBtns).toHaveLength(1);
expect(continueBtn).toHaveLength(1);
});
test('can choose plan and continue', async () => {
const siteData = getSiteData({
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);
expect(monthlyCheckboxEl.className).toEqual('gh-portal-btn active');
fireEvent.click(yearlyCheckboxEl);
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});
});

View file

@ -207,7 +207,7 @@ describe('Logged-in free member', () => {
// added fake timeout for react state delay in setting plan
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);
expect(ghostApi.member.checkoutPlan).toHaveBeenLastCalledWith({
@ -244,7 +244,7 @@ describe('Logged-in free member', () => {
// added fake timeout for react state delay in setting plan
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);
expect(ghostApi.member.checkoutPlan).toHaveBeenLastCalledWith({