Skip to content

Commit

Permalink
Rename files and add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
koechkevin committed Sep 20, 2023
1 parent 4d77b06 commit 7665eed
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const SinglePartner = React.forwardRef(function SinglePartner(

<ConnectBar title="Connect" links={connect} />
</Section>
{relatedProjects.length ? (
{relatedProjects?.length ? (
<>
<SectionDivider
sx={{
Expand Down
21 changes: 21 additions & 0 deletions apps/codeforafrica/src/components/Partner/Partner.snap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<Partners /> renders unchanged 1`] = `
<div>
<div
class="MuiBox-root css-1gghq2r"
>
<div
class="MuiContainer-root MuiContainer-maxWidthLg MuiContainer-fixed MuiContainer-disableGutters css-1ilq66o-MuiContainer-root"
>
<div
class="MuiBox-root css-15sqwg8"
>
Lorem ipsum dolor sit amet consectetur adipiscing, elit ac primis praesent
tempor luctus libero, curae condimentum ultricies proin leo. Arcu ornare dis fermentum nisi consequat imperdiet porta viverra placerat nullam, dapibus molestie faucibus id mi lacinia orci magnis. Ridiculus aptent phasellus mus nisi porta rutrum tellus, ut venenatis feugiat massa volutpat.
Duis maecenas per erat odio quisque accumsan, donec tempus class euismod vulputate fermentum imperdiet, suspendisse blandit lacinia semper cursus. Neque tristique posuere a feugiat convallis tempor cras nunc, leo faucibus cum aptent placerat aenean lobortis, nibh iaculis ac nascetur praesent mus quisque. Nullam leo rutrum augue urna cubilia morbi enim, arcu risus mus mauris elementum pulvinar, laoreet bibendum convallis senectus ullamcorper malesuada.
</div>
</div>
</div>
</div>
`;
30 changes: 30 additions & 0 deletions apps/codeforafrica/src/components/Partner/Partner.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { createRender } from "@commons-ui/testing-library";
import React from "react";

import Partner from "./Partner";

import theme from "@/codeforafrica/theme";

// eslint-disable-next-line testing-library/render-result-naming-convention
const render = createRender({ theme });

const defaultProps = {
description: [
{
text: "Lorem ipsum dolor sit amet consectetur adipiscing, elit ac primis praesent",
},
{
text: "tempor luctus libero, curae condimentum ultricies proin leo. Arcu ornare dis fermentum nisi consequat imperdiet porta viverra placerat nullam, dapibus molestie faucibus id mi lacinia orci magnis. Ridiculus aptent phasellus mus nisi porta rutrum tellus, ut venenatis feugiat massa volutpat. ",
},
{
text: "Duis maecenas per erat odio quisque accumsan, donec tempus class euismod vulputate fermentum imperdiet, suspendisse blandit lacinia semper cursus. Neque tristique posuere a feugiat convallis tempor cras nunc, leo faucibus cum aptent placerat aenean lobortis, nibh iaculis ac nascetur praesent mus quisque. Nullam leo rutrum augue urna cubilia morbi enim, arcu risus mus mauris elementum pulvinar, laoreet bibendum convallis senectus ullamcorper malesuada.",
},
],
};

describe("<Partners />", () => {
it("renders unchanged", () => {
const { container } = render(<Partner {...defaultProps} />);
expect(container).toMatchSnapshot();
});
});
3 changes: 3 additions & 0 deletions apps/codeforafrica/src/components/Partner/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import Partner from "./Partner";

export default Partner;
3 changes: 0 additions & 3 deletions apps/codeforafrica/src/components/SinglePartner/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion apps/codeforafrica/src/lib/data/blockify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const propsifyBlockBySlug = {

async function blockify(blocks) {
const promises = blocks?.map(async (block) => {
const slug = block.blockType ?? block.slug ?? null;
const slug = block.blockType;
const propsifyBlock = propsifyBlockBySlug[slug];

if (propsifyBlock) {
Expand Down
2 changes: 1 addition & 1 deletion apps/codeforafrica/src/lib/data/pagify/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const COLLECTION_BY_SLUG = {
async function pagify(parentPage, api, context) {
const { slug: collection } = parentPage;
const pageProps = COLLECTION_BY_SLUG[collection];
return pageProps(api, context);
return pageProps?.(api, context);
}

export default pagify;
2 changes: 1 addition & 1 deletion apps/codeforafrica/src/lib/data/pagify/partners.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function partners(api, context) {
{
relatedProjects: [], // TODO(koechkevin) Related projects go here once projects implemented
...partner,
slug: "partner",
blockType: "partner",
},
],
};
Expand Down
4 changes: 2 additions & 2 deletions apps/codeforafrica/src/pages/[...slugs].page.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import MeetOurTeam from "@/codeforafrica/components/MeetOurTeam";
import NewsAndStories from "@/codeforafrica/components/NewsAndStories";
import OurPartners from "@/codeforafrica/components/OurPartners";
import PageHeader from "@/codeforafrica/components/PageHeader";
import SinglePartner from "@/codeforafrica/components/SinglePartner";
import Partner from "@/codeforafrica/components/Partner";
import { getPageServerSideProps } from "@/codeforafrica/lib/data";

const componentsBySlugs = {
Expand All @@ -21,7 +21,7 @@ const componentsBySlugs = {
"our-impact": GetInvolved,
"our-partners": OurPartners,
projects: FeaturedProjects,
partner: SinglePartner,
partner: Partner,
};

function Index({ blocks, fallback }) {
Expand Down
2 changes: 1 addition & 1 deletion apps/codeforafrica/src/payload/blocks/OurPartners.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const Partners = {
slug: "our-partners",
imageURL: "/images/cms/blocks/partners.png",
imageAltText: "Our Partners List",
imageAltText: "Our Partners",
labels: {
singular: {
en: "Partners",
Expand Down

0 comments on commit 7665eed

Please sign in to comment.