Skip to content

Commit

Permalink
Format code with Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Dec 10, 2024
1 parent 85b3d84 commit 45a9d6a
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 64 deletions.
35 changes: 17 additions & 18 deletions web/__test__/screens/EventInformationScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,18 +101,18 @@ describe("EventInformationScreen", () => {
const errorMocks = [
{
request: {
query: getEventById({id: -1}),
query: getEventById({ id: -1 }),
},
error: new GraphQLError("Error!"),
},
];
Object.defineProperty(window, "location", {
value: { pathname: "/events/-1" },
});
value: { pathname: "/events/-1" },
});

render(
<MockedProvider mocks={errorMocks} addTypename={false}>
<MemoryRouter >
<MemoryRouter>
<EventInformationScreen navbar={<></>} />
</MemoryRouter>
</MockedProvider>
Expand All @@ -123,20 +123,19 @@ describe("EventInformationScreen", () => {
).toBeInTheDocument();
});

// it("renders queries correctly", async () => {
// Object.defineProperty(window, "location", {
// value: { pathname: "/events/1" },
// });

// render(
// <MockedProvider mocks={mocks} addTypename={false}>
// <MemoryRouter>
// <EventInformationScreen navbar={<></>} />
// </MemoryRouter>
// </MockedProvider>
// );
// it("renders queries correctly", async () => {
// Object.defineProperty(window, "location", {
// value: { pathname: "/events/1" },
// });

// expect(await screen.findByText("Event 1")).toBeInTheDocument();
// });
// render(
// <MockedProvider mocks={mocks} addTypename={false}>
// <MemoryRouter>
// <EventInformationScreen navbar={<></>} />
// </MemoryRouter>
// </MockedProvider>
// );

// expect(await screen.findByText("Event 1")).toBeInTheDocument();
// });
});
41 changes: 20 additions & 21 deletions web/__test__/screens/MembershipScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,22 @@ vi.mock("../../api/apiRequests", () => ({
}),
}));

// const mockedUseUserMembershipExpiry = vi.fn(() =>
// const mockedUseUserMembershipExpiry = vi.fn(() =>
// {
// data: {useUserMembershipExpiry: nextDate.toString()}
// }
// );
vi.mock("../hooks/api/useUserMembership", async () => {
const mod =
await vi.importActual<typeof import("../../src/hooks/api/useUserMembership")>(
"../../src/hooks/api/useUserMembership"
);
const mod = await vi.importActual<
typeof import("../../src/hooks/api/useUserMembership")
>("../../src/hooks/api/useUserMembership");
return {
...mod,
useUserMembershipExpiry: () => () => ({
data: { userExpiryDate : nextDate.toString()},
isLoading: false,
error: undefined
}),
data: { userExpiryDate: nextDate.toString() },
isLoading: false,
error: undefined,
}),
};
});

Expand Down Expand Up @@ -110,7 +109,7 @@ const noIntroMock = {
},
result: {
data: {
purchasableMemberships: {
purchasableMemberships: {
data: [],
},
},
Expand Down Expand Up @@ -164,17 +163,17 @@ describe("Membership Screen", () => {

// I was unable to figure out the mock for the tanstack query hook so will do this test case later

// it("renders purchase memberships correctly", async () => {

// render(
// <MockedProvider mocks={mocks} addTypename={false}>
// <QueryClientProvider client={queryClient}>
// <MemoryRouter>
// <MembershipScreen navbar={<></>} />
// </MemoryRouter>
// </QueryClientProvider>
// </MockedProvider>
// );
// it("renders purchase memberships correctly", async () => {

// render(
// <MockedProvider mocks={mocks} addTypename={false}>
// <QueryClientProvider client={queryClient}>
// <MemoryRouter>
// <MembershipScreen navbar={<></>} />
// </MemoryRouter>
// </QueryClientProvider>
// </MockedProvider>
// );

// expect(
// await screen.findByText("Your current membership expires on")
Expand Down
78 changes: 53 additions & 25 deletions web/__test__/screens/SignUpInformationScreen.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ vi.mock("react-router-dom", async () => {
});

describe("AboutUsScreen", () => {

it("renders questions correctly", async () => {
render(
<MockedProvider addTypename={false}>
<MockedProvider addTypename={false}>
<MemoryRouter>
<SignUpInformationScreen navbar={<></>} />
</MemoryRouter>
Expand All @@ -31,54 +30,83 @@ describe("AboutUsScreen", () => {

expect(await screen.findByText("Enter your name")).toBeInTheDocument();
expect(await screen.findByText("University ID number")).toBeInTheDocument();
expect(await screen.findByText("Enter your UPI number")).toBeInTheDocument();
expect(await screen.findByText("Enter your field of study")).toBeInTheDocument();
expect(await screen.findByText("Enter your year of study")).toBeInTheDocument();
expect(await screen.findByText("Enter student study status")).toBeInTheDocument();
expect(await screen.findByText("Enter the institute you study at")).toBeInTheDocument();
expect(
await screen.findByText("Enter your UPI number")
).toBeInTheDocument();
expect(
await screen.findByText("Enter your field of study")
).toBeInTheDocument();
expect(
await screen.findByText("Enter your year of study")
).toBeInTheDocument();
expect(
await screen.findByText("Enter student study status")
).toBeInTheDocument();
expect(
await screen.findByText("Enter the institute you study at")
).toBeInTheDocument();
});

it("does not render errors on load up", async () => {
render(
<MockedProvider addTypename={false}>
<MockedProvider addTypename={false}>
<MemoryRouter>
<SignUpInformationScreen navbar={<></>} />
</MemoryRouter>
</MockedProvider>
);
expect(await screen.queryByText("Please enter your full name")).toBeNull();
expect(await screen.queryByText("Please enter your ID number")).toBeNull();
expect(await screen.queryByText("Please enter your field of study")).toBeNull();
expect(await screen.queryByText("Please select a year of study")).toBeNull();
expect(
await screen.queryByText("Please enter your field of study")
).toBeNull();
expect(
await screen.queryByText("Please select a year of study")
).toBeNull();
expect(await screen.queryByText("Please enter your UPI")).toBeNull();
expect(await screen.queryByText("Please select a student status")).toBeNull();
expect(
await screen.queryByText("Please select a student status")
).toBeNull();
expect(await screen.queryByText("Please select an institute")).toBeNull();
});

it("renders error correctly", async () => {
render(
<MockedProvider addTypename={false}>
<MockedProvider addTypename={false}>
<MemoryRouter>
<SignUpInformationScreen navbar={<></>} />
</MemoryRouter>
</MockedProvider>
);

const button = await screen.findByRole("button", {
name: "Submit!",
});
expect(button).toBeDefined();
await fireEvent.click(button);
name: "Submit!",
});
expect(button).toBeDefined();
await fireEvent.click(button);

fireEvent.click(button)
fireEvent.click(button);

expect(await screen.findByText("Please enter your full name")).toBeInTheDocument();
expect(await screen.findByText("Please enter your ID number")).toBeInTheDocument();
expect(await screen.findByText("Please enter your field of study")).toBeInTheDocument();
expect(await screen.findByText("Please select a year of study")).toBeInTheDocument();
expect(await screen.findByText("Please enter your UPI")).toBeInTheDocument();
expect(await screen.findByText("Please select a student status")).toBeInTheDocument();
expect(await screen.findByText("Please select an institute")).toBeInTheDocument();
expect(
await screen.findByText("Please enter your full name")
).toBeInTheDocument();
expect(
await screen.findByText("Please enter your ID number")
).toBeInTheDocument();
expect(
await screen.findByText("Please enter your field of study")
).toBeInTheDocument();
expect(
await screen.findByText("Please select a year of study")
).toBeInTheDocument();
expect(
await screen.findByText("Please enter your UPI")
).toBeInTheDocument();
expect(
await screen.findByText("Please select a student status")
).toBeInTheDocument();
expect(
await screen.findByText("Please select an institute")
).toBeInTheDocument();
});

});

0 comments on commit 45a9d6a

Please sign in to comment.