0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-04-08 02:52:39 -05:00

Fixed plan tests

no refs
This commit is contained in:
Rishabh 2021-10-14 23:10:34 +05:30
parent cd2e30a337
commit 61c387b293
2 changed files with 10 additions and 7 deletions

View file

@ -1,5 +1,5 @@
import React from 'react';
import {generateAccountPlanFixture} from '../../utils/fixtures';
import {generateAccountPlanFixture, getSiteData, getProductsData} from '../../utils/fixtures';
import {render, fireEvent} from '../../utils/test-utils';
import AccountPlanPage from './AccountPlanPage';
@ -52,7 +52,10 @@ describe('Account Plan Page', () => {
});
test('can choose plan and continue', async () => {
const {mockOnActionFn, monthlyCheckboxEl, yearlyCheckboxEl, continueBtn} = setup();
const siteData = getSiteData({
products: getProductsData({numOfProducts: 1})
});
const {mockOnActionFn, monthlyCheckboxEl, yearlyCheckboxEl, continueBtn} = setup({site: siteData});
fireEvent.click(monthlyCheckboxEl);
expect(monthlyCheckboxEl.checked).toEqual(false);
fireEvent.click(yearlyCheckboxEl);
@ -60,7 +63,7 @@ describe('Account Plan Page', () => {
expect(continueBtn).toBeEnabled();
fireEvent.click(continueBtn);
expect(mockOnActionFn).toHaveBeenCalledWith('checkoutPlan', {plan: '6085adc776909b1a2382369a'});
expect(mockOnActionFn).toHaveBeenCalledWith('checkoutPlan', {plan: siteData.products[0].monthlyPrice.id});
});
test('can cancel subscription for member on hidden tier', async () => {

View file

@ -97,7 +97,7 @@ function getMemberData({
};
}
function getProductsData({numOfProducts = 3} = {}) {
export function getProductsData({numOfProducts = 3} = {}) {
const products = [
getProductData({
name: 'Bronze',
@ -107,7 +107,7 @@ function getProductsData({numOfProducts = 3} = {}) {
amount: 700
}),
yearlyPrice: getPriceData({
interval: 'month',
interval: 'year',
amount: 7000
}),
numOfBenefits: 2
@ -120,7 +120,7 @@ function getProductsData({numOfProducts = 3} = {}) {
amount: 1200
}),
yearlyPrice: getPriceData({
interval: 'month',
interval: 'year',
amount: 12000
}),
numOfBenefits: 3
@ -133,7 +133,7 @@ function getProductsData({numOfProducts = 3} = {}) {
amount: 2000
}),
yearlyPrice: getPriceData({
interval: 'month',
interval: 'year',
amount: 17000
}),
numOfBenefits: 4