import React from 'react'; import { composeStories } from '@storybook/testing-react'; import { render, within } from '@testing-library/react'; import * as stories from './PlanCard.stories'; const { PlanCardStory, CurrentPlanStory } = composeStories(stories); describe('PlanCard', () => { it('should render the render', () => { const { container } = render(); expect(container).toBeDefined(); }); it('should render plan description', () => { const { getByText } = render(); PlanCardStory.args?.description?.forEach((feature) => { expect(getByText(feature, { exact: false })).toBeDefined(); }); }); it('should render description title', () => { const { getByText } = render(); expect( getByText(`${PlanCardStory.args?.descriptionTitle}`, { exact: false, }), ).toBeDefined(); }); it('should render footer', () => { render(); if (PlanCardStory?.args?.footer) { expect( within(PlanCardStory?.args?.footer as unknown as HTMLElement), ).toBeDefined(); } }); it('should render title', () => { render(); if (PlanCardStory?.args?.title) { expect( within(PlanCardStory?.args?.title as unknown as HTMLElement), ).toBeDefined(); } }); it('should render your plan', () => { const { getByText } = render(); expect(getByText('Your Plan', { exact: false })).toBeDefined(); }); });