Skip to content

Commit

Permalink
Migrate components to Typescript (#1808)
Browse files Browse the repository at this point in the history
  • Loading branch information
recondesigns committed Mar 12, 2024
1 parent 6933f2d commit 61d5bf9
Show file tree
Hide file tree
Showing 33 changed files with 652 additions and 117 deletions.
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

0 comments on commit 61d5bf9

Please sign in to comment.