test: classes data
This commit is contained in:
parent
af0ee540dc
commit
44051e6343
3 changed files with 8 additions and 5 deletions
|
@ -2,6 +2,7 @@ import { beforeAll, describe, expect, it } from 'vitest';
|
|||
import { ClassRepository } from '../../../src/data/classes/class-repository';
|
||||
import { setupTestApp } from '../../setup-tests';
|
||||
import { getClassRepository } from '../../../src/data/repositories';
|
||||
import { getClass01, getClass04 } from '../../test_assets/classes/classes.testdata';
|
||||
|
||||
describe('ClassRepository', () => {
|
||||
let classRepository: ClassRepository;
|
||||
|
@ -18,16 +19,18 @@ describe('ClassRepository', () => {
|
|||
});
|
||||
|
||||
it('should return requested class', async () => {
|
||||
const classVar = await classRepository.findById('8764b861-90a6-42e5-9732-c0d9eb2f55f9');
|
||||
const expected = getClass01();
|
||||
const classVar = await classRepository.findById(expected.classId!);
|
||||
|
||||
expect(classVar).toBeTruthy();
|
||||
expect(classVar?.displayName).toBe('class01');
|
||||
expect(classVar?.displayName).toBe(expected.displayName);
|
||||
});
|
||||
|
||||
it('class should be gone after deletion', async () => {
|
||||
await classRepository.deleteById('33d03536-83b8-4880-9982-9bbf2f908ddf');
|
||||
const deleted = getClass04();
|
||||
await classRepository.deleteById(deleted.classId!);
|
||||
|
||||
const classVar = await classRepository.findById('33d03536-83b8-4880-9982-9bbf2f908ddf');
|
||||
const classVar = await classRepository.findById(deleted.classId!);
|
||||
|
||||
expect(classVar).toBeNull();
|
||||
});
|
||||
|
|
|
@ -39,6 +39,7 @@ export function makeTestClasses(em: EntityManager): Class[] {
|
|||
const studentsClass04: Student[] = [getNoordkaap(), getDireStraits()];
|
||||
const teacherClass04: Teacher[] = [getStaind()];
|
||||
|
||||
// gets deleted in test
|
||||
class04 = em.create(Class, {
|
||||
classId: '33d03536-83b8-4880-9982-9bbf2f908ddf',
|
||||
displayName: 'class04',
|
||||
|
|
|
@ -9,7 +9,6 @@ export const TEST_STUDENTS = [
|
|||
{ username: 'SmashingPumpkins', firstName: 'Billy', lastName: 'Corgan' },
|
||||
{ username: 'PinkFloyd', firstName: 'David', lastName: 'Gilmoure' },
|
||||
{ username: 'TheDoors', firstName: 'Jim', lastName: 'Morisson' },
|
||||
// ⚠️ Deze mag niet gebruikt worden in elke test!
|
||||
{ username: 'Nirvana', firstName: 'Kurt', lastName: 'Cobain' },
|
||||
// Makes sure when logged in as leerling1, there exists a corresponding user
|
||||
{ username: 'testleerling1', firstName: 'Gerald', lastName: 'Schmittinger' },
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue