2025SELab2-project-Dwengo/backend/tests/data/users.test.ts
Gerald Schmittinger 73a84fa3ef fix(backend): .js aan alle imports toegevoegd
Dit was nodig om ervoor te zorgen dat de gebouwde applicatie ook haar dependencies vindt.
2025-02-26 22:43:16 +01:00

33 lines
1.3 KiB
TypeScript

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));
let 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);
let retrievedStudent = await studentRepository.findByUsername(username);
expect(retrievedStudent).toBeNull();
});
});