Skip to content

Commit

Permalink
updates factory
Browse files Browse the repository at this point in the history
  • Loading branch information
rosschapman committed Dec 24, 2024
1 parent 1089492 commit 8bfccf3
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/components/ui/Cards/EventCard.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { EventCard } from "./EventCard";
import { HOME_PAGE_EVENTS_DATA_FORMATTED } from "../../../../test/fixtures/EventsData";
import { createFormattedHomePageEventsData } from "../../../../test/fixtures/EventsData";

describe("<EventCard />", () => {
const eventData = HOME_PAGE_EVENTS_DATA_FORMATTED[0];
const eventData = createFormattedHomePageEventsData()[0];

it("displays title, link, date, and call to action", () => {
render(<EventCard event={eventData} />);
Expand Down
4 changes: 2 additions & 2 deletions app/components/ui/Cards/EventCardSection.test.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { HOME_PAGE_EVENTS_DATA_FORMATTED } from "../../../../test/fixtures/EventsData";
import { createFormattedHomePageEventsData } from "../../../../test/fixtures/EventsData";
import { EventCardSection } from "components/ui/Cards/EventCardSection";

describe("<EventCardSection />", () => {
const eventData = HOME_PAGE_EVENTS_DATA_FORMATTED;
const eventData = createFormattedHomePageEventsData();

it("displays the correct number of event cards", () => {
render(<EventCardSection events={eventData} />);
Expand Down
5 changes: 0 additions & 5 deletions app/pages/EventDetailPage/EventDetailPage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { render, screen } from "@testing-library/react";
import { EventDetailPage } from "pages/EventDetailPage/EventDetailPage";
import { EVENTS_DATA } from "../../../test/fixtures/EventsData";
import { useEventData } from "hooks/StrapiAPI";
import { BrowserRouter } from "react-router-dom";
import { HelmetProvider } from "react-helmet-async";

let MOCK_EVENT: {
Expand All @@ -17,10 +16,6 @@ let MOCK_EVENT: {
};

jest.mock("hooks/StrapiAPI", () => ({
// TODO: This shouldn't have to be mocked here but I'm not quite an expert
// enough yet in jest mocking to figure out how to import the fixtures without
// doing this.
formatHomePageEventsData: () => null,
useEventData: () => MOCK_EVENT,
}));

Expand Down
27 changes: 14 additions & 13 deletions test/fixtures/EventsData.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Sample data from a real api request to our Strapi production server. This
// data may have to change as the api changes so developers should feel at
// liberty to update these fixtures as needed.

import { RootNode } from "@strapi/blocks-react-renderer/dist/BlocksRenderer";
import { formatHomePageEventsData } from "hooks/StrapiAPI";

// liberty to update these fixtures as needed.
export const EVENTS_DATA = [
{
data: {
Expand Down Expand Up @@ -1386,15 +1386,16 @@ export const EVENTS_DATA = [
},
];

export const HOME_PAGE_EVENTS_DATA_FORMATTED = formatHomePageEventsData({
data: [
{
id: EVENTS_DATA[0].data.id,
attributes: EVENTS_DATA[0].data.attributes,
},
{
id: EVENTS_DATA[1].data.id,
attributes: EVENTS_DATA[1].data.attributes,
},
],
});
export const createFormattedHomePageEventsData = () =>
formatHomePageEventsData({
data: [
{
id: EVENTS_DATA[0].data.id,
attributes: EVENTS_DATA[0].data.attributes,
},
{
id: EVENTS_DATA[1].data.id,
attributes: EVENTS_DATA[1].data.attributes,
},
],
});

0 comments on commit 8bfccf3

Please sign in to comment.