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,52 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository';
import {
getAssignmentRepository,
getClassRepository,
} from '../../../src/data/repositories';
import { ClassRepository } from '../../../src/data/classes/class-repository';
describe('AssignmentRepository', () => {
let assignmentRepository: AssignmentRepository;
let classRepository: ClassRepository;
beforeAll(async () => {
await setupTestApp();
assignmentRepository = getAssignmentRepository();
classRepository = getClassRepository();
});
it('should return the requested assignment', async () => {
const class_ = await classRepository.findById('id02');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
2
);
expect(assignment).toBeTruthy();
expect(assignment!.title).toBe('tool');
});
it('should return all assignments for a class', async () => {
const class_ = await classRepository.findById('id02');
const assignments =
await assignmentRepository.findAllAssignmentsInClass(class_!);
expect(assignments).toBeTruthy();
expect(assignments).toHaveLength(1);
expect(assignments[0].title).toBe('tool');
});
it('should not find removed assignment', async () => {
const class_ = await classRepository.findById('id01');
await assignmentRepository.deleteByClassAndId(class_!, 3);
const assignment = await assignmentRepository.findByClassAndId(
class_!,
3
);
expect(assignment).toBeNull();
});
});

View file

@ -0,0 +1,70 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { GroupRepository } from '../../../src/data/assignments/group-repository';
import {
getAssignmentRepository,
getClassRepository,
getGroupRepository,
} from '../../../src/data/repositories';
import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository';
import { ClassRepository } from '../../../src/data/classes/class-repository';
describe('GroupRepository', () => {
let groupRepository: GroupRepository;
let assignmentRepository: AssignmentRepository;
let classRepository: ClassRepository;
beforeAll(async () => {
await setupTestApp();
groupRepository = getGroupRepository();
assignmentRepository = getAssignmentRepository();
classRepository = getClassRepository();
});
it('should return the requested group', async () => {
const class_ = await classRepository.findById('id01');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
1
);
const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!,
1
);
expect(group).toBeTruthy();
});
it('should return all groups for assignment', async () => {
const class_ = await classRepository.findById('id01');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
1
);
const groups = await groupRepository.findAllGroupsForAssignment(
assignment!
);
expect(groups).toBeTruthy();
expect(groups).toHaveLength(3);
});
it('should not find removed group', async () => {
const class_ = await classRepository.findById('id02');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
2
);
await groupRepository.deleteByAssignmentAndGroupNumber(assignment!, 1);
const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!,
1
);
expect(group).toBeNull();
});
});

View file

@ -0,0 +1,95 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { SubmissionRepository } from '../../../src/data/assignments/submission-repository';
import {
getAssignmentRepository,
getClassRepository,
getGroupRepository,
getStudentRepository,
getSubmissionRepository,
} from '../../../src/data/repositories';
import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier';
import { Language } from '../../../src/entities/content/language';
import { StudentRepository } from '../../../src/data/users/student-repository';
import { GroupRepository } from '../../../src/data/assignments/group-repository';
import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository';
import { ClassRepository } from '../../../src/data/classes/class-repository';
describe('SubmissionRepository', () => {
let submissionRepository: SubmissionRepository;
let studentRepository: StudentRepository;
let groupRepository: GroupRepository;
let assignmentRepository: AssignmentRepository;
let classRepository: ClassRepository;
beforeAll(async () => {
await setupTestApp();
submissionRepository = getSubmissionRepository();
studentRepository = getStudentRepository();
groupRepository = getGroupRepository();
assignmentRepository = getAssignmentRepository();
classRepository = getClassRepository();
});
it('should find the requested submission', async () => {
const id = new LearningObjectIdentifier('id03', Language.English, '1');
const submission =
await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(
id,
1
);
expect(submission).toBeTruthy();
expect(submission?.content).toBe('sub1');
});
it('should find the most recent submission for a student', async () => {
const id = new LearningObjectIdentifier('id02', Language.English, '1');
const student = await studentRepository.findByUsername('Noordkaap');
const submission =
await submissionRepository.findMostRecentSubmissionForStudent(
id,
student!
);
expect(submission).toBeTruthy();
expect(submission?.submissionTime.getDate()).toBe(25);
});
it('should find the most recent submission for a group', async () => {
const id = new LearningObjectIdentifier('id03', Language.English, '1');
const class_ = await classRepository.findById('id01');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
1
);
const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!,
1
);
const submission =
await submissionRepository.findMostRecentSubmissionForGroup(
id,
group!
);
expect(submission).toBeTruthy();
expect(submission?.submissionTime.getDate()).toBe(25);
});
it('should not find a deleted submission', async () => {
const id = new LearningObjectIdentifier('id01', Language.English, '1');
await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(
id,
1
);
const submission =
await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(
id,
1
);
expect(submission).toBeNull();
});
});