Merge branch 'dev' into chore/logging

This commit is contained in:
Tibo De Peuter 2025-03-02 15:04:04 +01:00
commit f82668148c
Signed by: tdpeuter
GPG key ID: 38297DE43F75FFE2
122 changed files with 6026 additions and 14446 deletions

View file

@ -0,0 +1,33 @@
import {setupTestApp} from "../setup-tests.js"
import {Student} from "../../src/entities/users/student.entity.js";
import {describe, it, expect, beforeAll} from "vitest";
import {StudentRepository} from "../../src/data/users/student-repository.js";
import {getStudentRepository} from "../../src/data/repositories.js";
const username = "teststudent";
const firstName = "John";
const lastName = "Doe";
describe("StudentRepository", () => {
let studentRepository: StudentRepository;
beforeAll(async () => {
await setupTestApp();
studentRepository = getStudentRepository();
});
it("should return the queried student after he was added", async () => {
await studentRepository.insert(new Student(username, firstName, lastName));
const retrievedStudent = await studentRepository.findByUsername(username);
expect(retrievedStudent).toBeTruthy();
expect(retrievedStudent?.firstName).toBe(firstName);
expect(retrievedStudent?.lastName).toBe(lastName);
});
it("should no longer return the queried student after he was removed again", async () => {
await studentRepository.deleteByUsername(username);
const retrievedStudent = await studentRepository.findByUsername(username);
expect(retrievedStudent).toBeNull();
});
});