style: verander de structuur van de testmap
This commit is contained in:
parent
5f55da987c
commit
678ced55ba
27 changed files with 854 additions and 706 deletions
52
backend/tests/data/assignments/assignments.test.ts
Normal file
52
backend/tests/data/assignments/assignments.test.ts
Normal 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();
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue