Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate components to Typescript #1808

Merged
merged 11 commits into from
Mar 12, 2024
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import DonateSection from '../DonateSection';
type DonateSectionStoryType = StoryObj<React.FC>;

const meta: Meta<typeof DonateSection> = {
title: 'Reusable/DonateSection',
title: 'ReusableSections/DonateSection',
component: DonateSection,
};

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Meta, StoryObj } from '@storybook/react';
import JoinSection from '../JoinSection';

type JoinSectionStoryType = StoryObj<typeof JoinSection>;

const meta: Meta<typeof JoinSection> = {
title: 'ReusableSections/JoinSection',
component: JoinSection,
};

export default meta;

export const Default: JoinSectionStoryType = {
render: () => <JoinSection />,
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@ import Heading from 'components/Heading/Heading';
import PartnerLogoLink from 'components/PartnerLogoLink/PartnerLogoLink';
import partners, { PARTNER_TYPES } from 'common/constants/partners';

const isPaidSponsor = partner => partner.type === PARTNER_TYPES.PAID;
type Partner = {
name: string;
type: string;
};

const isPaidSponsor = (partner: Partner): boolean => partner.type === PARTNER_TYPES.PAID;

const SponsorsSection = () => (
<Container theme="gray">
<Container theme="gray" data-testid="Sponsors Section">
<Heading text="Sponsors" hasTitleUnderline headingLevel={3} />

<Heading text="Corporate Partners" headingLevel={4} />
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Meta, StoryObj } from '@storybook/react'
import SponsorsSection from '../SponsorsSection';

type SponsorsSectionStoryType = StoryObj<typeof SponsorsSection>

const meta: Meta<typeof SponsorsSection> = {
title: 'ReusableSections/SponsorsSection',
component: SponsorsSection
}

export default meta

export const Default: SponsorsSectionStoryType = {
render: () => <SponsorsSection />
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
import { render } from '@testing-library/react';
import createSnapshotTest from 'test-utils/createSnapshotTest';
import partners from 'common/constants/partners';

import SponsorsSection from '../SponsorsSection';

describe('SponsorsSection', () => {
it('should render', () => {
const { queryByTestId } = render(<SponsorsSection />);
expect(queryByTestId('Sponsors Section')).not.toBeNull();

createSnapshotTest(<SponsorsSection />);
});

it('should render a secure link and image for each partner', () => {
const component = render(<SponsorsSection>Test</SponsorsSection>);
const component = render(<SponsorsSection />);

partners.forEach(partner => {
const image = component.queryByAltText(`${partner.name} logo`);
const link = image.parentNode;
const image = component.queryByAltText(`${partner.name} logo`)!;
const link = image.parentNode as HTMLAnchorElement;

expect(image).toBeInTheDocument();
expect(link.href.startsWith('https://')).toStrictEqual(true);
Expand Down
Loading
Loading