Skip to content

Commit

Permalink
test: write tests
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinWu098 committed Dec 27, 2023
1 parent f967f67 commit 2317faa
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions __tests__/search-filters.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ const data = {
cvcId: "123456",
niceToHaves: ["Zero Textbook Cost"],
units: 4,
term: "Mar 11 - May 25",
term: "January 1 - May 31",
startMonth: 1,
startDay: 1,
endMonth: 6,
endDay: 1,
endMonth: 5,
endDay: 31,
tuition: 138,
async: true,
hasOpenSeats: true,
Expand All @@ -38,7 +38,7 @@ const data = {
cvcId: "1234567",
niceToHaves: ["Zero Textbook Cost"],
units: 16,
term: "Mar 11 - May 25",
term: "January 1 - June 1",
startMonth: 1,
startDay: 1,
endMonth: 6,
Expand All @@ -52,6 +52,27 @@ const data = {
articulatesTo: ["placeholder course 2"],
fulfillsGEs: ["II"],
},
{
sendingInstitution: "placeholder sending institution 3",
courseCode: "placeholder course code 3",
courseName: "placeholder course name 3",
cvcId: "1234567",
niceToHaves: ["Zero Textbook Cost"],
units: 16,
term: "January 1 - June 1",
startMonth: 12,
startDay: 30,
endMonth: 1,
endDay: 1,
tuition: 100,
async: false,
hasOpenSeats: false,
hasPrereqs: false,
instantEnrollment: false,
assistPath: "placeholder path 3",
articulatesTo: ["placeholder course 3"],
fulfillsGEs: ["II"],
},
],
};

Expand Down Expand Up @@ -242,4 +263,24 @@ describe("Search Sorting", () => {
"placeholder sending institution 2",
);
});

test("shortest term sorts correctly", async () => {
const result = filterData(data.courses.slice(0, 2), {
...defaultFilterValues,
sort: "Shortest Term",
});
expect(result[0].sendingInstitution).toEqual(
"placeholder sending institution 1",
);
});

test("shortest term sorts correctly on december courses", async () => {
const result = filterData(data.courses, {
...defaultFilterValues,
sort: "Shortest Term",
});
expect(result[0].sendingInstitution).toEqual(
"placeholder sending institution 3",
);
});
});

0 comments on commit 2317faa

Please sign in to comment.