test: teacher data
This commit is contained in:
parent
db9b9ce2cd
commit
af0ee540dc
1 changed files with 7 additions and 5 deletions
|
@ -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();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue