test: teacher data

This commit is contained in:
laurejablonski 2025-04-27 11:06:42 +02:00
parent db9b9ce2cd
commit af0ee540dc

View file

@ -2,6 +2,7 @@ import { describe, it, expect, beforeAll } from 'vitest';
import { TeacherRepository } from '../../../src/data/users/teacher-repository';
import { setupTestApp } from '../../setup-tests';
import { getTeacherRepository } from '../../../src/data/repositories';
import { getFooFighters } from '../../test_assets/users/teachers.testdata';
const username = 'testteacher';
const firstName = 'John';
@ -21,11 +22,12 @@ describe('TeacherRepository', () => {
});
it('should return teacher from the datbase', async () => {
const teacher = await teacherRepository.findByUsername('FooFighters');
const expected = getFooFighters();
const teacher = await teacherRepository.findByUsername(expected.username);
expect(teacher).toBeTruthy();
expect(teacher?.firstName).toBe('Dave');
expect(teacher?.lastName).toBe('Grohl');
expect(teacher?.firstName).toBe(expected.firstName);
expect(teacher?.lastName).toBe(expected.lastName);
});
it('should return the queried teacher after he was added', async () => {
@ -38,9 +40,9 @@ describe('TeacherRepository', () => {
});
it('should no longer return the queried teacher after he was removed again', async () => {
await teacherRepository.deleteByUsername('ZesdeMetaal');
await teacherRepository.deleteByUsername(username);
const retrievedTeacher = await teacherRepository.findByUsername('ZesdeMetaal');
const retrievedTeacher = await teacherRepository.findByUsername(username);
expect(retrievedTeacher).toBeNull();
});
});