Skip to content

Commit

Permalink
edit test
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank404NotFound committed May 31, 2024
1 parent 59eb1a5 commit ace257c
Showing 1 changed file with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import CourseOverTimeIndexPage from "main/pages/CourseOverTime/CourseOverTimeInd
import { apiCurrentUserFixtures } from "fixtures/currentUserFixtures";
import { systemInfoFixtures } from "fixtures/systemInfoFixtures";
import { threeSections } from "fixtures/sectionFixtures";
import { threeSectionsDiffQrts } from "fixtures/sectionFixtures";
import { allTheSubjects } from "fixtures/subjectFixtures";
import userEvent from "@testing-library/user-event";

Expand Down Expand Up @@ -95,4 +96,47 @@ describe("CourseOverTimeIndexPage tests", () => {

expect(screen.getByText("ECE 1A")).toBeInTheDocument();
});

test("sorts courses in descending order by quarter", async () => {
axiosMock.onGet("/api/UCSBSubjects/all").reply(200, allTheSubjects);
axiosMock
.onGet("/api/public/courseovertime/search")
.reply(200, threeSectionsDiffQrts);

render(
<QueryClientProvider client={queryClient}>
<MemoryRouter>
<CourseOverTimeIndexPage />
</MemoryRouter>
</QueryClientProvider>,
);

const selectStartQuarter = screen.getByLabelText("Start Quarter");
userEvent.selectOptions(selectStartQuarter, "20211");
const selectEndQuarter = screen.getByLabelText("End Quarter");
userEvent.selectOptions(selectEndQuarter, "20221");
const selectSubject = screen.getByLabelText("Subject Area");
userEvent.selectOptions(selectSubject, "ECE");
const enterCourseNumber = screen.getByLabelText(
"Course Number (Try searching '16' or '130A')",
);
userEvent.type(enterCourseNumber, "1");

const submitButton = screen.getByText("Submit");
expect(submitButton).toBeInTheDocument();
userEvent.click(submitButton);

await waitFor(() => {
expect(screen.getByText("COMP ENGR SEMINAR")).toBeInTheDocument();
});

const rows = screen.getAllByRole("row");
const [firstRow, secondRow, thirdRow] = rows
.slice(1, 4)
.map((row) => row.textContent);

expect(firstRow).toContain("M22");
expect(secondRow).toContain("S22");
expect(thirdRow).toContain("W22");
});
});

0 comments on commit ace257c

Please sign in to comment.