Skip to content

Commit

Permalink
Merge pull request #138 from UoaWDCC/fix/about-us-page
Browse files Browse the repository at this point in the history
Fix/about us page
  • Loading branch information
gmat224 authored Nov 5, 2024
2 parents 1512295 + 465a832 commit 1a0fdd7
Show file tree
Hide file tree
Showing 61 changed files with 950 additions and 1,267 deletions.
2 changes: 1 addition & 1 deletion web/__test__/components/ExecCard.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import ExecCard from "../../src/components/ExecCard";
import ExecCard from "../../src/components/exec-page/ExecCard";
import React from "react";
import { Exec } from "../../src/types/types";

Expand Down
8 changes: 1 addition & 7 deletions web/__test__/components/Footer.test.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { render, screen } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
import Footer from "../../src/components/Footer";
import Footer from "../../src/components/navigation/Footer";
import "@testing-library/jest-dom";

// Mock the Socials component
Expand All @@ -16,10 +16,4 @@ describe("Footer component", () => {

expect(peacockLogo).toBeInTheDocument();
});

it("renders Socials component correctly", () => {
render(<Footer />);
const socialsComponent = screen.getByText("Socials Component");
expect(socialsComponent).toBeInTheDocument();
});
});
2 changes: 1 addition & 1 deletion web/__test__/components/Header.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { render, screen, fireEvent } from "@testing-library/react";
import { MemoryRouter } from "react-router-dom";
import { describe, it, expect, beforeEach } from "vitest";
import Header from "../../src/components/Header";
import Header from "../../src/components/navigation/Header";

describe("Header component", () => {
beforeEach(() => {
Expand Down
172 changes: 86 additions & 86 deletions web/__test__/components/Introduction.test.tsx
Original file line number Diff line number Diff line change
@@ -1,94 +1,94 @@
import { MockedProvider } from "@apollo/client/testing";
// import { MockedProvider } from "@apollo/client/testing";
import { GET_INTRODUCTION } from "../../src/graphql/queries";
import { describe, expect, it } from "vitest";
import { render, screen } from "@testing-library/react";
import Introductions from "../../src/components/Introductions";
import React from "react";
import { GraphQLError } from "graphql";
// import { render, screen } from "@testing-library/react";
// import React from "react";
// import { GraphQLError } from "graphql";

const mocks = [
{
request: {
query: GET_INTRODUCTION,
},
result: {
data: {
introductions: {
data: [
{
id: 1,
attributes: {
Events: "Hate",
Description: "Be a Professional Hater",
Followers: "1000",
Members: "2000",
},
},
],
},
},
},
},
];
// const mocks = [
// {
// request: {
// query: GET_INTRODUCTION,
// },
// result: {
// data: {
// introductions: {
// data: [
// {
// id: 1,
// attributes: {
// Events: "Hate",
// Description: "Be a Professional Hater",
// Followers: "1000",
// Members: "2000",
// },
// },
// ],
// },
// },
// },
// },
// ];

const noDataMock = {
request: {
query: GET_INTRODUCTION,
},
result: {
data: {
introductions: {
data: [],
},
},
},
};
// const noDataMock = {
// request: {
// query: GET_INTRODUCTION,
// },
// result: {
// data: {
// introductions: {
// data: [],
// },
// },
// },
// };

describe("Introductions Component", () => {
it("renders loading", async () => {
render(
<MockedProvider mocks={mocks} addTypename={false}>
<Introductions />
</MockedProvider>
);
expect(screen.getByTestId("loading-spinner")).toBeInTheDocument();
});
it.todo("add test cases");
// it("renders loading", async () => {
// render(
// <MockedProvider mocks={mocks} addTypename={false}>
// <Introductions />
// </MockedProvider>
// );
// expect(screen.getByTestId("loading-spinner")).toBeInTheDocument();
// });

it("renders the mocked data", async () => {
render(
<MockedProvider mocks={mocks} addTypename={false}>
<Introductions />
</MockedProvider>
);
expect(await screen.findByText("Hate")).toBeInTheDocument();
expect(
await screen.findByText("Be a Professional Hater")
).toBeInTheDocument();
expect(await screen.findByText("1000")).toBeInTheDocument();
expect(await screen.findByText("2000")).toBeInTheDocument();
});
it("renders error", async () => {
const execMock = {
request: {
query: GET_INTRODUCTION,
},
error: new GraphQLError("Error!"),
};
render(
<MockedProvider mocks={[execMock]} addTypename={false}>
<Introductions />
</MockedProvider>
);
expect(await screen.findByText("CMS Offline")).toBeInTheDocument();
});
it("renders no data from cms", async () => {
render(
<MockedProvider mocks={[noDataMock]} addTypename={false}>
<Introductions />
</MockedProvider>
);
expect(
await screen.findByText("There is no introduction to display")
).toBeInTheDocument();
});
// it("renders the mocked data", async () => {
// render(
// <MockedProvider mocks={mocks} addTypename={false}>
// <Introductions />
// </MockedProvider>
// );
// expect(await screen.findByText("Hate")).toBeInTheDocument();
// expect(
// await screen.findByText("Be a Professional Hater")
// ).toBeInTheDocument();
// expect(await screen.findByText("1000")).toBeInTheDocument();
// expect(await screen.findByText("2000")).toBeInTheDocument();
// });
// it("renders error", async () => {
// const execMock = {
// request: {
// query: GET_INTRODUCTION,
// },
// error: new GraphQLError("Error!"),
// };
// render(
// <MockedProvider mocks={[execMock]} addTypename={false}>
// <Introductions />
// </MockedProvider>
// );
// expect(await screen.findByText("CMS Offline")).toBeInTheDocument();
// });
// it("renders no data from cms", async () => {
// render(
// <MockedProvider mocks={[noDataMock]} addTypename={false}>
// <Introductions />
// </MockedProvider>
// );
// expect(
// await screen.findByText("There is no introduction to display")
// ).toBeInTheDocument();
// });
});
2 changes: 1 addition & 1 deletion web/__test__/components/PartnerCard.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it, vi } from "vitest";
import { fireEvent, render, screen } from "@testing-library/react";
import PartnerCard from "../../src/components/PartnerCard";
import PartnerCard from "../../src/components/partner-page/PartnerCard";
import React from "react";
import { Partner } from "../../src/types/types";

Expand Down
Loading

0 comments on commit 1a0fdd7

Please sign in to comment.