fix: extra frontend tests
This commit is contained in:
parent
9af2f136eb
commit
1d84d60737
5 changed files with 195 additions and 38 deletions
|
@ -1,10 +1,59 @@
|
|||
import { describe, expect, it } from "vitest";
|
||||
import { describe, it, expect, beforeEach } from "vitest";
|
||||
import { ClassController } from "../../src/controllers/classes";
|
||||
|
||||
describe("Test controller classes", () => {
|
||||
it("Get classes", async () => {
|
||||
const controller = new ClassController();
|
||||
const data = await controller.getAll(true);
|
||||
expect(data.classes).to.have.length.greaterThan(0);
|
||||
describe("ClassController Tests", () => {
|
||||
let controller: ClassController;
|
||||
const testClassId = "X2J9QT";
|
||||
|
||||
beforeEach(() => {
|
||||
controller = new ClassController();
|
||||
});
|
||||
|
||||
it("should fetch all classes", async () => {
|
||||
const result = await controller.getAll(true);
|
||||
expect(result).toHaveProperty("classes");
|
||||
expect(Array.isArray(result.classes)).toBe(true);
|
||||
expect(result.classes.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
it("should fetch a class by ID", async () => {
|
||||
const result = await controller.getById(testClassId);
|
||||
expect(result).toHaveProperty("class");
|
||||
expect(result.class).toHaveProperty("id", testClassId);
|
||||
});
|
||||
|
||||
|
||||
it("should fetch students for a class", async () => {
|
||||
const result = await controller.getStudents(testClassId, true);
|
||||
expect(result).toHaveProperty("students");
|
||||
expect(Array.isArray(result.students)).toBe(true);
|
||||
});
|
||||
|
||||
it("should fetch teachers for a class", async () => {
|
||||
const result = await controller.getTeachers(testClassId, true);
|
||||
expect(result).toHaveProperty("teachers");
|
||||
expect(Array.isArray(result.teachers)).toBe(true);
|
||||
});
|
||||
|
||||
it("should fetch teacher invitations for a class", async () => {
|
||||
const result = await controller.getTeacherInvitations(testClassId, true);
|
||||
expect(result).toHaveProperty("invitations");
|
||||
expect(Array.isArray(result.invitations)).toBe(true);
|
||||
});
|
||||
|
||||
it("should fetch assignments for a class", async () => {
|
||||
const result = await controller.getAssignments(testClassId, true);
|
||||
expect(result).toHaveProperty("assignments");
|
||||
expect(Array.isArray(result.assignments)).toBe(true);
|
||||
});
|
||||
|
||||
it("should handle fetching a non-existent class", async () => {
|
||||
const nonExistentId = "NON_EXISTENT_ID";
|
||||
await expect(controller.getById(nonExistentId)).rejects.toThrow();
|
||||
});
|
||||
|
||||
it("should handle deleting a non-existent class", async () => {
|
||||
const nonExistentId = "NON_EXISTENT_ID";
|
||||
await expect(controller.deleteClass(nonExistentId)).rejects.toThrow();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue