style: verander de structuur van de testmap

This commit is contained in:
Laure Jablonski 2025-03-10 21:01:09 +01:00
parent 5f55da987c
commit 678ced55ba
27 changed files with 854 additions and 706 deletions

View file

@ -0,0 +1,35 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import {
getAttachmentRepository,
getLearningObjectRepository,
} from '../../../src/data/repositories';
import { AttachmentRepository } from '../../../src/data/content/attachment-repository';
import { LearningObjectRepository } from '../../../src/data/content/learning-object-repository';
import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier';
import { Language } from '../../../src/entities/content/language';
describe('AttachmentRepository', () => {
let attachmentRepository: AttachmentRepository;
let learningObjectRepository: LearningObjectRepository;
beforeAll(async () => {
await setupTestApp();
attachmentRepository = getAttachmentRepository();
learningObjectRepository = getLearningObjectRepository();
});
it('should return the requested attachment', async () => {
const id = new LearningObjectIdentifier('id02', Language.English, '1');
const learningObject =
await learningObjectRepository.findByIdentifier(id);
const attachment =
await attachmentRepository.findByLearningObjectAndNumber(
learningObject!,
1
);
expect(attachment).toBeTruthy();
});
});

View file

@ -0,0 +1,34 @@
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;
beforeAll(async () => {
await setupTestApp();
learningObjectRepository = getLearningObjectRepository();
});
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);
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);
expect(learningObject).toBeNull();
});
});

View file

@ -0,0 +1,36 @@
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;
beforeAll(async () => {
await setupTestApp();
learningPathRepository = getLearningPathRepository();
});
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(
'id01',
Language.English
);
expect(learningPath).toBeTruthy();
expect(learningPath?.title).toBe('repertoire Tool');
expect(learningPath?.description).toBe('all about Tool');
});
});