From aa31141c605b245262135e11f9295d012283d997 Mon Sep 17 00:00:00 2001 From: Eddy Chen <89349085+ecxyzzy@users.noreply.github.com> Date: Fri, 25 Aug 2023 22:14:29 -0700 Subject: [PATCH] test: :rotating_light: add regression test for #83 --- tests/api/src/tests/v1/rest/grades.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/api/src/tests/v1/rest/grades.ts diff --git a/tests/api/src/tests/v1/rest/grades.ts b/tests/api/src/tests/v1/rest/grades.ts new file mode 100644 index 00000000..8a37e37d --- /dev/null +++ b/tests/api/src/tests/v1/rest/grades.ts @@ -0,0 +1,21 @@ +import { assert, describe, expect, it } from "vitest"; + +describe("/v1/rest/grades tests", () => { + it("returns zeros for nonexistent aggregate", async () => { + const res = await get("/v1/rest/grades/aggregate?year=2013"); + assert("payload" in res); + expect(res.payload).toHaveProperty("sectionList", []); + assert(typeof res.payload === "object"); + assert(res.payload !== null); + assert("gradeDistribution" in res.payload); + expect(res.payload.gradeDistribution).toHaveProperty("gradeACount", 0); + expect(res.payload.gradeDistribution).toHaveProperty("gradeBCount", 0); + expect(res.payload.gradeDistribution).toHaveProperty("gradeCCount", 0); + expect(res.payload.gradeDistribution).toHaveProperty("gradeDCount", 0); + expect(res.payload.gradeDistribution).toHaveProperty("gradeFCount", 0); + expect(res.payload.gradeDistribution).toHaveProperty("gradePCount", 0); + expect(res.payload.gradeDistribution).toHaveProperty("gradeNPCount", 0); + expect(res.payload.gradeDistribution).toHaveProperty("gradeWCount", 0); + expect(res.payload.gradeDistribution).toHaveProperty("averageGPA", 0); + }); +});