test: students data

This commit is contained in:
laurejablonski 2025-04-27 11:04:17 +02:00
parent 8f113d02b4
commit db9b9ce2cd
2 changed files with 7 additions and 3 deletions

View file

@ -2,6 +2,8 @@ import { setupTestApp } from '../../setup-tests.js';
import { describe, it, expect, beforeAll } from 'vitest';
import { StudentRepository } from '../../../src/data/users/student-repository.js';
import { getStudentRepository } from '../../../src/data/repositories.js';
import { getNameOfJSDocTypedef } from 'typescript';
import { getNoordkaap } from '../../test_assets/users/students.testdata.js';
const username = 'teststudent';
const firstName = 'John';
@ -21,11 +23,12 @@ describe('StudentRepository', () => {
});
it('should return student from the datbase', async () => {
const student = await studentRepository.findByUsername('Noordkaap');
const expectation = getNoordkaap();
const student = await studentRepository.findByUsername(expectation.username);
expect(student).toBeTruthy();
expect(student?.firstName).toBe('Stijn');
expect(student?.lastName).toBe('Meuris');
expect(student?.firstName).toBe(expectation.firstName);
expect(student?.lastName).toBe(expectation.lastName);
});
it('should return the queried student after he was added', async () => {

View file

@ -4,6 +4,7 @@ import { testLearningObject01 } from './learning-objects.testdata';
import { LearningObject } from '../../../src/entities/content/learning-object.entity';
export function makeTestAttachments(em: EntityManager): Attachment[] {
// prevent duplicate insertion
const lo = em.merge(LearningObject, testLearningObject01);
attachment01 = em.create(Attachment, {