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
58
backend/tests/data/classes/class-join-request.test.ts
Normal file
58
backend/tests/data/classes/class-join-request.test.ts
Normal file
|
@ -0,0 +1,58 @@
|
|||
import { beforeAll, describe, expect, it } from 'vitest';
|
||||
import { setupTestApp } from '../../setup-tests';
|
||||
import { ClassJoinRequestRepository } from '../../../src/data/classes/class-join-request-repository';
|
||||
import {
|
||||
getClassJoinRequestRepository,
|
||||
getClassRepository,
|
||||
getStudentRepository,
|
||||
} from '../../../src/data/repositories';
|
||||
import { StudentRepository } from '../../../src/data/users/student-repository';
|
||||
import { Class } from '../../../src/entities/classes/class.entity';
|
||||
import { ClassRepository } from '../../../src/data/classes/class-repository';
|
||||
import { Student } from '../../../src/entities/users/student.entity';
|
||||
|
||||
describe('ClassJoinRequestRepository', () => {
|
||||
let classJoinRequestRepository: ClassJoinRequestRepository;
|
||||
let studentRepository: StudentRepository;
|
||||
let cassRepository: ClassRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
classJoinRequestRepository = getClassJoinRequestRepository();
|
||||
studentRepository = getStudentRepository();
|
||||
cassRepository = getClassRepository();
|
||||
});
|
||||
|
||||
it('should list all requests from student to join classes', async () => {
|
||||
const student = await studentRepository.findByUsername('PinkFloyd');
|
||||
const requests = await classJoinRequestRepository.findAllRequestsBy(
|
||||
student!
|
||||
);
|
||||
|
||||
expect(requests).toBeTruthy();
|
||||
expect(requests).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('should list all requests to a single class', async () => {
|
||||
const class_ = await cassRepository.findById('id02');
|
||||
const requests = await classJoinRequestRepository.findAllOpenRequestsTo(
|
||||
class_!
|
||||
);
|
||||
|
||||
expect(requests).toBeTruthy();
|
||||
expect(requests).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('should not find a removed request', async () => {
|
||||
const student =
|
||||
await studentRepository.findByUsername('SmashingPumpkins');
|
||||
const class_ = await cassRepository.findById('id03');
|
||||
await classJoinRequestRepository.deleteBy(student!, class_!);
|
||||
|
||||
const request = await classJoinRequestRepository.findAllRequestsBy(
|
||||
student!
|
||||
);
|
||||
|
||||
expect(request).toHaveLength(0);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue