test: zet alle data klaar in de setup file en pas reeds gemaakte testen aan om met deze data te werken
This commit is contained in:
parent
595f248f11
commit
fcd9f66e28
6 changed files with 498 additions and 102 deletions
|
@ -12,22 +12,22 @@ describe('ClassRepository', () => {
|
|||
});
|
||||
|
||||
it('should return nothing because id does not exist', async () => {
|
||||
const classVar = await ClassRepository.findById('id');
|
||||
const classVar = await ClassRepository.findById('test_id');
|
||||
|
||||
expect(classVar).toBeNull();
|
||||
});
|
||||
|
||||
it('should return requested class', async () => {
|
||||
const classVar = await ClassRepository.findById('class_id01');
|
||||
const classVar = await ClassRepository.findById('id01');
|
||||
|
||||
expect(classVar).toBeTruthy();
|
||||
expect(classVar?.displayName).toBe('class01');
|
||||
});
|
||||
|
||||
it('class should be gone after deletion', async () => {
|
||||
await ClassRepository.deleteById('class_id01');
|
||||
await ClassRepository.deleteById('id04');
|
||||
|
||||
const classVar = await ClassRepository.findById('class_id01');
|
||||
const classVar = await ClassRepository.findById('id04');
|
||||
|
||||
expect(classVar).toBeNull();
|
||||
});
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { beforeAll, describe, expect, it } from "vitest";
|
||||
import { LearningObjectRepository } from "../../src/data/content/learning-object-repository";
|
||||
import { getLearningObjectRepository } from "../../src/data/repositories";
|
||||
import { setupTestApp } from "../setup-tests";
|
||||
import { LearningObjectIdentifier } from "../../src/entities/content/learning-object-identifier";
|
||||
import { Language } from "../../src/entities/content/language";
|
||||
import { beforeAll, describe, expect, it } from 'vitest';
|
||||
import { LearningObjectRepository } from '../../src/data/content/learning-object-repository';
|
||||
import { getLearningObjectRepository } from '../../src/data/repositories';
|
||||
import { setupTestApp } from '../setup-tests';
|
||||
import { LearningObjectIdentifier } from '../../src/entities/content/learning-object-identifier';
|
||||
import { Language } from '../../src/entities/content/language';
|
||||
|
||||
describe('LearningObjectRepository', () => {
|
||||
let LearningObjectRepository: LearningObjectRepository;
|
||||
|
@ -13,19 +13,21 @@ describe('LearningObjectRepository', () => {
|
|||
LearningObjectRepository = getLearningObjectRepository();
|
||||
});
|
||||
|
||||
const id01 = new LearningObjectIdentifier('hruid_object01', Language.English, '1');
|
||||
const id02 = new LearningObjectIdentifier('hruid_object06', Language.English, '1');
|
||||
const id01 = new LearningObjectIdentifier('id01', Language.English, '1');
|
||||
const id02 = new LearningObjectIdentifier('test_id', Language.English, '1');
|
||||
|
||||
it('should return the learning object that matches identifier 1', async() => {
|
||||
const learningObject = await LearningObjectRepository.findByIdentifier(id01);
|
||||
it('should return the learning object that matches identifier 1', async () => {
|
||||
const learningObject =
|
||||
await LearningObjectRepository.findByIdentifier(id01);
|
||||
|
||||
expect(learningObject).toBeTruthy();
|
||||
expect(learningObject?.title).toBe('Undertow');
|
||||
expect(learningObject?.description).toBe('debute');
|
||||
});
|
||||
|
||||
it('should return nothing because the identifier does not exist in the database', async() => {
|
||||
const learningObject = await LearningObjectRepository.findByIdentifier(id02);
|
||||
it('should return nothing because the identifier does not exist in the database', async () => {
|
||||
const learningObject =
|
||||
await LearningObjectRepository.findByIdentifier(id02);
|
||||
|
||||
expect(learningObject).toBeNull();
|
||||
});
|
||||
|
|
|
@ -1,29 +1,36 @@
|
|||
import { beforeAll, describe, expect, it } from "vitest";
|
||||
import { LearningPathRepository } from "../../src/data/content/learning-path-repository";
|
||||
import { getLearningPathRepository } from "../../src/data/repositories";
|
||||
import { setupTestApp } from "../setup-tests";
|
||||
import { Language } from "../../src/entities/content/language";
|
||||
import { beforeAll, describe, expect, it } from 'vitest';
|
||||
import { getLearningPathRepository } from '../../src/data/repositories';
|
||||
import { LearningPathRepository } from '../../src/data/content/learning-path-repository';
|
||||
import { setupTestApp } from '../setup-tests';
|
||||
import { Language } from '../../src/entities/content/language';
|
||||
|
||||
describe('LearningPathRepository', () => {
|
||||
let LearningPathRepository : LearningPathRepository;
|
||||
let LearningPathRepository: LearningPathRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
LearningPathRepository = getLearningPathRepository();
|
||||
});
|
||||
|
||||
it('should return nothing because no match for hruid and language', async() => {
|
||||
const learningPath = await LearningPathRepository.findByHruidAndLanguage('hruid_path01', Language.Dutch);
|
||||
it('should return nothing because no match for hruid and language', async () => {
|
||||
const learningPath =
|
||||
await LearningPathRepository.findByHruidAndLanguage(
|
||||
'test_id',
|
||||
Language.Dutch
|
||||
);
|
||||
|
||||
expect(learningPath).toBeNull();
|
||||
});
|
||||
|
||||
it('should return requested learning path', async() => {
|
||||
const learningPath = await LearningPathRepository.findByHruidAndLanguage('hruid_path01', Language.English);
|
||||
it('should return requested learning path', async () => {
|
||||
const learningPath =
|
||||
await LearningPathRepository.findByHruidAndLanguage(
|
||||
'id01',
|
||||
Language.English
|
||||
);
|
||||
|
||||
expect(learningPath).toBeTruthy();
|
||||
expect(learningPath?.title).toBe('repertoire Tool');
|
||||
expect(learningPath?.description).toBe('all about Tool');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,19 +15,19 @@ describe('StudentRepository', () => {
|
|||
studentRepository = getStudentRepository();
|
||||
});
|
||||
|
||||
it('should not return a student because username does not exist', async() => {
|
||||
it('should not return a student because username does not exist', async () => {
|
||||
const student = await studentRepository.findByUsername('test');
|
||||
|
||||
expect(student).toBeNull();
|
||||
});
|
||||
|
||||
it('should return student from the datbase', async() => {
|
||||
const student = await studentRepository.findByUsername('DireStraits');
|
||||
it('should return student from the datbase', async () => {
|
||||
const student = await studentRepository.findByUsername('Noordkaap');
|
||||
|
||||
expect(student).toBeTruthy();
|
||||
expect(student?.firstName).toBe('Mark');
|
||||
expect(student?.lastName).toBe('Knopfler');
|
||||
})
|
||||
expect(student?.firstName).toBe('Stijn');
|
||||
expect(student?.lastName).toBe('Meuris');
|
||||
});
|
||||
|
||||
it('should return the queried student after he was added', async () => {
|
||||
await studentRepository.insert(
|
||||
|
@ -42,10 +42,10 @@ describe('StudentRepository', () => {
|
|||
});
|
||||
|
||||
it('should no longer return the queried student after he was removed again', async () => {
|
||||
await studentRepository.deleteByUsername(username);
|
||||
await studentRepository.deleteByUsername('Nirvana');
|
||||
|
||||
const retrievedStudent =
|
||||
await studentRepository.findByUsername(username);
|
||||
await studentRepository.findByUsername('Nirvana');
|
||||
expect(retrievedStudent).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -15,19 +15,19 @@ describe('TeacherRepository', () => {
|
|||
TeacherRepository = getTeacherRepository();
|
||||
});
|
||||
|
||||
it('should not return a teacher because username does not exist', async() => {
|
||||
it('should not return a teacher because username does not exist', async () => {
|
||||
const teacher = await TeacherRepository.findByUsername('test');
|
||||
|
||||
expect(teacher).toBeNull();
|
||||
});
|
||||
|
||||
it('should return teacher from the datbase', async() => {
|
||||
const teacher = await TeacherRepository.findByUsername('Tool');
|
||||
it('should return teacher from the datbase', async () => {
|
||||
const teacher = await TeacherRepository.findByUsername('FooFighters');
|
||||
|
||||
expect(teacher).toBeTruthy();
|
||||
expect(teacher?.firstName).toBe('Maynard');
|
||||
expect(teacher?.lastName).toBe('Keenan');
|
||||
})
|
||||
expect(teacher?.firstName).toBe('Dave');
|
||||
expect(teacher?.lastName).toBe('Grohl');
|
||||
});
|
||||
|
||||
it('should return the queried teacher after he was added', async () => {
|
||||
await TeacherRepository.insert(
|
||||
|
@ -42,10 +42,10 @@ describe('TeacherRepository', () => {
|
|||
});
|
||||
|
||||
it('should no longer return the queried teacher after he was removed again', async () => {
|
||||
await TeacherRepository.deleteByUsername(username);
|
||||
await TeacherRepository.deleteByUsername('ZesdeMetaal');
|
||||
|
||||
const retrievedTeacher =
|
||||
await TeacherRepository.findByUsername(username);
|
||||
await TeacherRepository.findByUsername('ZesdeMetaal');
|
||||
expect(retrievedTeacher).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue