style: verander namen van variabelen zodat ze beginnen met een kleine letter

This commit is contained in:
Laure Jablonski 2025-03-10 19:24:09 +01:00
parent 4aa2dfc7d3
commit da8e27acfd
12 changed files with 125 additions and 125 deletions

View file

@ -13,21 +13,21 @@ import { Question } from '../../src/entities/questions/question.entity';
import { TeacherRepository } from '../../src/data/users/teacher-repository'; import { TeacherRepository } from '../../src/data/users/teacher-repository';
describe('AnswerRepository', () => { describe('AnswerRepository', () => {
let AnswerRepository: AnswerRepository; let answerRepository: AnswerRepository;
let QuestionRepository: QuestionRepository; let questionRepository: QuestionRepository;
let TeacherRepository: TeacherRepository; let teacherRepository: TeacherRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
AnswerRepository = getAnswerRepository(); answerRepository = getAnswerRepository();
QuestionRepository = getQuestionRepository(); questionRepository = getQuestionRepository();
TeacherRepository = getTeacherRepository(); teacherRepository = getTeacherRepository();
}); });
it('should find all answers to a question', async () => { it('should find all answers to a question', async () => {
const id = new LearningObjectIdentifier('id05', Language.English, '1'); const id = new LearningObjectIdentifier('id05', Language.English, '1');
const questions = const questions =
await QuestionRepository.findAllQuestionsAboutLearningObject(id); await questionRepository.findAllQuestionsAboutLearningObject(id);
let question: Question; let question: Question;
if (questions[0].sequenceNumber == 2) { if (questions[0].sequenceNumber == 2) {
question = questions[0]; question = questions[0];
@ -35,7 +35,7 @@ describe('AnswerRepository', () => {
question = questions[1]; question = questions[1];
} }
const answers = const answers =
await AnswerRepository.findAllAnswersToQuestion(question); await answerRepository.findAllAnswersToQuestion(question);
expect(answers).toBeTruthy(); expect(answers).toBeTruthy();
expect(answers).toHaveLength(2); expect(answers).toHaveLength(2);
@ -69,14 +69,14 @@ describe('AnswerRepository', () => {
it('should not find a removed answer', async () => { it('should not find a removed answer', async () => {
const id = new LearningObjectIdentifier('id04', Language.English, '1'); const id = new LearningObjectIdentifier('id04', Language.English, '1');
const questions = const questions =
await QuestionRepository.findAllQuestionsAboutLearningObject(id); await questionRepository.findAllQuestionsAboutLearningObject(id);
await AnswerRepository.removeAnswerByQuestionAndSequenceNumber( await answerRepository.removeAnswerByQuestionAndSequenceNumber(
questions[0], questions[0],
1 1
); );
const emptyList = await AnswerRepository.findAllAnswersToQuestion( const emptyList = await answerRepository.findAllAnswersToQuestion(
questions[0] questions[0]
); );

View file

@ -8,18 +8,18 @@ import {
import { ClassRepository } from '../../src/data/classes/class-repository'; import { ClassRepository } from '../../src/data/classes/class-repository';
describe('AssignmentRepository', () => { describe('AssignmentRepository', () => {
let AssignmentRepository: AssignmentRepository; let assignmentRepository: AssignmentRepository;
let ClassRepository: ClassRepository; let classRepository: ClassRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
AssignmentRepository = getAssignmentRepository(); assignmentRepository = getAssignmentRepository();
ClassRepository = getClassRepository(); classRepository = getClassRepository();
}); });
it('should return the requested assignment', async () => { it('should return the requested assignment', async () => {
const class_ = await ClassRepository.findById('id02'); const class_ = await classRepository.findById('id02');
const assignment = await AssignmentRepository.findByClassAndId( const assignment = await assignmentRepository.findByClassAndId(
class_!, class_!,
2 2
); );
@ -29,19 +29,19 @@ describe('AssignmentRepository', () => {
}); });
it('should return all assignments for a class', async () => { it('should return all assignments for a class', async () => {
const class_ = await ClassRepository.findById('id02'); const class_ = await classRepository.findById('id02');
const assignments = const assignments =
await AssignmentRepository.findAllAssignmentsInClass(class_!); await assignmentRepository.findAllAssignmentsInClass(class_!);
expect(assignments).toBeTruthy(); expect(assignments).toBeTruthy();
expect(assignments).toHaveLength(1); expect(assignments).toHaveLength(1);
}); });
it('should not find removed assignment', async () => { it('should not find removed assignment', async () => {
const class_ = await ClassRepository.findById('id01'); const class_ = await classRepository.findById('id01');
await AssignmentRepository.deleteByClassAndId(class_!, 3); await assignmentRepository.deleteByClassAndId(class_!, 3);
const assignment = await AssignmentRepository.findByClassAndId( const assignment = await assignmentRepository.findByClassAndId(
class_!, class_!,
3 3
); );

View file

@ -10,22 +10,22 @@ import { LearningObjectIdentifier } from '../../src/entities/content/learning-ob
import { Language } from '../../src/entities/content/language'; import { Language } from '../../src/entities/content/language';
describe('AttachmentRepository', () => { describe('AttachmentRepository', () => {
let AttachmentRepository: AttachmentRepository; let attachmentRepository: AttachmentRepository;
let LearningObjectRepository: LearningObjectRepository; let learningObjectRepository: LearningObjectRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
AttachmentRepository = getAttachmentRepository(); attachmentRepository = getAttachmentRepository();
LearningObjectRepository = getLearningObjectRepository(); learningObjectRepository = getLearningObjectRepository();
}); });
it('should return the requested attachment', async () => { it('should return the requested attachment', async () => {
const id = new LearningObjectIdentifier('id02', Language.English, '1'); const id = new LearningObjectIdentifier('id02', Language.English, '1');
const learningObject = const learningObject =
await LearningObjectRepository.findByIdentifier(id); await learningObjectRepository.findByIdentifier(id);
const attachment = const attachment =
await AttachmentRepository.findByLearningObjectAndNumber( await attachmentRepository.findByLearningObjectAndNumber(
learningObject!, learningObject!,
1 1
); );

View file

@ -12,20 +12,20 @@ import { ClassRepository } from '../../src/data/classes/class-repository';
import { Student } from '../../src/entities/users/student.entity'; import { Student } from '../../src/entities/users/student.entity';
describe('ClassJoinRequestRepository', () => { describe('ClassJoinRequestRepository', () => {
let ClassJoinRequestRepository: ClassJoinRequestRepository; let classJoinRequestRepository: ClassJoinRequestRepository;
let StudentRepository: StudentRepository; let studentRepository: StudentRepository;
let ClassRepository: ClassRepository; let cassRepository: ClassRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
ClassJoinRequestRepository = getClassJoinRequestRepository(); classJoinRequestRepository = getClassJoinRequestRepository();
StudentRepository = getStudentRepository(); studentRepository = getStudentRepository();
ClassRepository = getClassRepository(); cassRepository = getClassRepository();
}); });
it('should list all requests from student to join classes', async () => { it('should list all requests from student to join classes', async () => {
const student = await StudentRepository.findByUsername('PinkFloyd'); const student = await studentRepository.findByUsername('PinkFloyd');
const requests = await ClassJoinRequestRepository.findAllRequestsBy( const requests = await classJoinRequestRepository.findAllRequestsBy(
student! student!
); );
@ -34,8 +34,8 @@ describe('ClassJoinRequestRepository', () => {
}); });
it('should list all requests to a single class', async () => { it('should list all requests to a single class', async () => {
const class_ = await ClassRepository.findById('id02'); const class_ = await cassRepository.findById('id02');
const requests = await ClassJoinRequestRepository.findAllOpenRequestsTo( const requests = await classJoinRequestRepository.findAllOpenRequestsTo(
class_! class_!
); );
@ -45,11 +45,11 @@ describe('ClassJoinRequestRepository', () => {
it('should not find a removed request', async () => { it('should not find a removed request', async () => {
const student = const student =
await StudentRepository.findByUsername('SmashingPumpkins'); await studentRepository.findByUsername('SmashingPumpkins');
const class_ = await ClassRepository.findById('id03'); const class_ = await cassRepository.findById('id03');
await ClassJoinRequestRepository.deleteBy(student!, class_!); await classJoinRequestRepository.deleteBy(student!, class_!);
const request = await ClassJoinRequestRepository.findAllRequestsBy( const request = await classJoinRequestRepository.findAllRequestsBy(
student! student!
); );

View file

@ -4,30 +4,30 @@ import { setupTestApp } from '../setup-tests';
import { getClassRepository } from '../../src/data/repositories'; import { getClassRepository } from '../../src/data/repositories';
describe('ClassRepository', () => { describe('ClassRepository', () => {
let ClassRepository: ClassRepository; let classRepository: ClassRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
ClassRepository = getClassRepository(); classRepository = getClassRepository();
}); });
it('should return nothing because id does not exist', async () => { it('should return nothing because id does not exist', async () => {
const classVar = await ClassRepository.findById('test_id'); const classVar = await classRepository.findById('test_id');
expect(classVar).toBeNull(); expect(classVar).toBeNull();
}); });
it('should return requested class', async () => { it('should return requested class', async () => {
const classVar = await ClassRepository.findById('id01'); const classVar = await classRepository.findById('id01');
expect(classVar).toBeTruthy(); expect(classVar).toBeTruthy();
expect(classVar?.displayName).toBe('class01'); expect(classVar?.displayName).toBe('class01');
}); });
it('class should be gone after deletion', async () => { it('class should be gone after deletion', async () => {
await ClassRepository.deleteById('id04'); await classRepository.deleteById('id04');
const classVar = await ClassRepository.findById('id04'); const classVar = await classRepository.findById('id04');
expect(classVar).toBeNull(); expect(classVar).toBeNull();
}); });

View file

@ -11,25 +11,25 @@ import { ClassRepository } from '../../src/data/classes/class-repository';
import { Class } from '../../src/entities/classes/class.entity'; import { Class } from '../../src/entities/classes/class.entity';
describe('GroupRepository', () => { describe('GroupRepository', () => {
let GroupRepository: GroupRepository; let groupRepository: GroupRepository;
let AssignmentRepository: AssignmentRepository; let assignmentRepository: AssignmentRepository;
let ClassRepository: ClassRepository; let classRepository: ClassRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
GroupRepository = getGroupRepository(); groupRepository = getGroupRepository();
AssignmentRepository = getAssignmentRepository(); assignmentRepository = getAssignmentRepository();
ClassRepository = getClassRepository(); classRepository = getClassRepository();
}); });
it('should return the requested group', async () => { it('should return the requested group', async () => {
const class_ = await ClassRepository.findById('id01'); const class_ = await classRepository.findById('id01');
const assignment = await AssignmentRepository.findByClassAndId( const assignment = await assignmentRepository.findByClassAndId(
class_!, class_!,
1 1
); );
const group = await GroupRepository.findByAssignmentAndGroupNumber( const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!, assignment!,
1 1
); );
@ -38,13 +38,13 @@ describe('GroupRepository', () => {
}); });
it('should return all groups for assignment', async () => { it('should return all groups for assignment', async () => {
const class_ = await ClassRepository.findById('id01'); const class_ = await classRepository.findById('id01');
const assignment = await AssignmentRepository.findByClassAndId( const assignment = await assignmentRepository.findByClassAndId(
class_!, class_!,
1 1
); );
const groups = await GroupRepository.findAllGroupsForAssignment( const groups = await groupRepository.findAllGroupsForAssignment(
assignment! assignment!
); );
@ -53,15 +53,15 @@ describe('GroupRepository', () => {
}); });
it('should not find removed group', async () => { it('should not find removed group', async () => {
const class_ = await ClassRepository.findById('id02'); const class_ = await classRepository.findById('id02');
const assignment = await AssignmentRepository.findByClassAndId( const assignment = await assignmentRepository.findByClassAndId(
class_!, class_!,
2 2
); );
await GroupRepository.deleteByAssignmentAndGroupNumber(assignment!, 1); await groupRepository.deleteByAssignmentAndGroupNumber(assignment!, 1);
const group = await GroupRepository.findByAssignmentAndGroupNumber( const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!, assignment!,
1 1
); );

View file

@ -6,11 +6,11 @@ import { LearningObjectIdentifier } from '../../src/entities/content/learning-ob
import { Language } from '../../src/entities/content/language'; import { Language } from '../../src/entities/content/language';
describe('LearningObjectRepository', () => { describe('LearningObjectRepository', () => {
let LearningObjectRepository: LearningObjectRepository; let learningObjectRepository: LearningObjectRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
LearningObjectRepository = getLearningObjectRepository(); learningObjectRepository = getLearningObjectRepository();
}); });
const id01 = new LearningObjectIdentifier('id01', Language.English, '1'); const id01 = new LearningObjectIdentifier('id01', Language.English, '1');
@ -18,7 +18,7 @@ describe('LearningObjectRepository', () => {
it('should return the learning object that matches identifier 1', async () => { it('should return the learning object that matches identifier 1', async () => {
const learningObject = const learningObject =
await LearningObjectRepository.findByIdentifier(id01); await learningObjectRepository.findByIdentifier(id01);
expect(learningObject).toBeTruthy(); expect(learningObject).toBeTruthy();
expect(learningObject?.title).toBe('Undertow'); expect(learningObject?.title).toBe('Undertow');
@ -27,7 +27,7 @@ describe('LearningObjectRepository', () => {
it('should return nothing because the identifier does not exist in the database', async () => { it('should return nothing because the identifier does not exist in the database', async () => {
const learningObject = const learningObject =
await LearningObjectRepository.findByIdentifier(id02); await learningObjectRepository.findByIdentifier(id02);
expect(learningObject).toBeNull(); expect(learningObject).toBeNull();
}); });

View file

@ -5,16 +5,16 @@ import { setupTestApp } from '../setup-tests';
import { Language } from '../../src/entities/content/language'; import { Language } from '../../src/entities/content/language';
describe('LearningPathRepository', () => { describe('LearningPathRepository', () => {
let LearningPathRepository: LearningPathRepository; let learningPathRepository: LearningPathRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
LearningPathRepository = getLearningPathRepository(); learningPathRepository = getLearningPathRepository();
}); });
it('should return nothing because no match for hruid and language', async () => { it('should return nothing because no match for hruid and language', async () => {
const learningPath = const learningPath =
await LearningPathRepository.findByHruidAndLanguage( await learningPathRepository.findByHruidAndLanguage(
'test_id', 'test_id',
Language.Dutch Language.Dutch
); );
@ -24,7 +24,7 @@ describe('LearningPathRepository', () => {
it('should return requested learning path', async () => { it('should return requested learning path', async () => {
const learningPath = const learningPath =
await LearningPathRepository.findByHruidAndLanguage( await learningPathRepository.findByHruidAndLanguage(
'id01', 'id01',
Language.English Language.English
); );

View file

@ -13,21 +13,21 @@ import { Language } from '../../src/entities/content/language';
import { Question } from '../../src/entities/questions/question.entity'; import { Question } from '../../src/entities/questions/question.entity';
describe('QuestionRepository', () => { describe('QuestionRepository', () => {
let QuestionRepository: QuestionRepository; let questionRepository: QuestionRepository;
let StudentRepository: StudentRepository; let studentRepository: StudentRepository;
let LearningObjectRepository: LearningObjectRepository; let learningObjectRepository: LearningObjectRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
QuestionRepository = getQuestionRepository(); questionRepository = getQuestionRepository();
StudentRepository = getStudentRepository(); studentRepository = getStudentRepository();
LearningObjectRepository = getLearningObjectRepository(); learningObjectRepository = getLearningObjectRepository();
}); });
it('should return all questions part of the given learning object', async () => { it('should return all questions part of the given learning object', async () => {
const id = new LearningObjectIdentifier('id05', Language.English, '1'); const id = new LearningObjectIdentifier('id05', Language.English, '1');
const questions = const questions =
await QuestionRepository.findAllQuestionsAboutLearningObject(id); await questionRepository.findAllQuestionsAboutLearningObject(id);
expect(questions).toBeTruthy(); expect(questions).toBeTruthy();
expect(questions).toHaveLength(2); expect(questions).toHaveLength(2);
@ -50,13 +50,13 @@ describe('QuestionRepository', () => {
it('should not find removed question', async () => { it('should not find removed question', async () => {
const id = new LearningObjectIdentifier('id04', Language.English, '1'); const id = new LearningObjectIdentifier('id04', Language.English, '1');
await QuestionRepository.removeQuestionByLearningObjectAndSequenceNumber( await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(
id, id,
1 1
); );
const question = const question =
await QuestionRepository.findAllQuestionsAboutLearningObject(id); await questionRepository.findAllQuestionsAboutLearningObject(id);
expect(question).toHaveLength(0); expect(question).toHaveLength(0);
}); });

View file

@ -19,25 +19,25 @@ import { AssignmentRepository } from '../../src/data/assignments/assignment-repo
import { ClassRepository } from '../../src/data/classes/class-repository'; import { ClassRepository } from '../../src/data/classes/class-repository';
describe('SubmissionRepository', () => { describe('SubmissionRepository', () => {
let SubmissionRepository: SubmissionRepository; let submissionRepository: SubmissionRepository;
let StudentRepository: StudentRepository; let studentRepository: StudentRepository;
let GroupRepository: GroupRepository; let groupRepository: GroupRepository;
let AssignmentRepository: AssignmentRepository; let assignmentRepository: AssignmentRepository;
let ClassRepository: ClassRepository; let classRepository: ClassRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
SubmissionRepository = getSubmissionRepository(); submissionRepository = getSubmissionRepository();
StudentRepository = getStudentRepository(); studentRepository = getStudentRepository();
GroupRepository = getGroupRepository(); groupRepository = getGroupRepository();
AssignmentRepository = getAssignmentRepository(); assignmentRepository = getAssignmentRepository();
ClassRepository = getClassRepository(); classRepository = getClassRepository();
}); });
it('should find the requested submission', async () => { it('should find the requested submission', async () => {
const id = new LearningObjectIdentifier('id03', Language.English, '1'); const id = new LearningObjectIdentifier('id03', Language.English, '1');
const submission = const submission =
await SubmissionRepository.findSubmissionByLearningObjectAndSubmissionNumber( await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(
id, id,
1 1
); );
@ -48,9 +48,9 @@ describe('SubmissionRepository', () => {
it('should find the most recent submission for a student', async () => { it('should find the most recent submission for a student', async () => {
const id = new LearningObjectIdentifier('id02', Language.English, '1'); const id = new LearningObjectIdentifier('id02', Language.English, '1');
const student = await StudentRepository.findByUsername('Noordkaap'); const student = await studentRepository.findByUsername('Noordkaap');
const submission = const submission =
await SubmissionRepository.findMostRecentSubmissionForStudent( await submissionRepository.findMostRecentSubmissionForStudent(
id, id,
student! student!
); );
@ -61,17 +61,17 @@ describe('SubmissionRepository', () => {
it('should find the most recent submission for a group', async () => { it('should find the most recent submission for a group', async () => {
const id = new LearningObjectIdentifier('id03', Language.English, '1'); const id = new LearningObjectIdentifier('id03', Language.English, '1');
const class_ = await ClassRepository.findById('id01'); const class_ = await classRepository.findById('id01');
const assignment = await AssignmentRepository.findByClassAndId( const assignment = await assignmentRepository.findByClassAndId(
class_!, class_!,
1 1
); );
const group = await GroupRepository.findByAssignmentAndGroupNumber( const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!, assignment!,
1 1
); );
const submission = const submission =
await SubmissionRepository.findMostRecentSubmissionForGroup( await submissionRepository.findMostRecentSubmissionForGroup(
id, id,
group! group!
); );
@ -82,13 +82,13 @@ describe('SubmissionRepository', () => {
it('should not find a deleted submission', async () => { it('should not find a deleted submission', async () => {
const id = new LearningObjectIdentifier('id01', Language.English, '1'); const id = new LearningObjectIdentifier('id01', Language.English, '1');
await SubmissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber( await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(
id, id,
1 1
); );
const submission = const submission =
await SubmissionRepository.findSubmissionByLearningObjectAndSubmissionNumber( await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(
id, id,
1 1
); );

View file

@ -10,39 +10,39 @@ import { TeacherRepository } from '../../src/data/users/teacher-repository';
import { ClassRepository } from '../../src/data/classes/class-repository'; import { ClassRepository } from '../../src/data/classes/class-repository';
describe('ClassRepository', () => { describe('ClassRepository', () => {
let TeacherInvitationRepository: TeacherInvitationRepository; let teacherInvitationRepository: TeacherInvitationRepository;
let TeacherRepository: TeacherRepository; let teacherRepository: TeacherRepository;
let ClassRepository: ClassRepository; let classRepository: ClassRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
TeacherInvitationRepository = getTeacherInvitationRepository(); teacherInvitationRepository = getTeacherInvitationRepository();
TeacherRepository = getTeacherRepository(); teacherRepository = getTeacherRepository();
ClassRepository = getClassRepository(); classRepository = getClassRepository();
}); });
it('should return all invitations from a teacher', async () => { it('should return all invitations from a teacher', async () => {
const teacher = await TeacherRepository.findByUsername('LimpBizkit'); const teacher = await teacherRepository.findByUsername('LimpBizkit');
const invitations = const invitations =
await TeacherInvitationRepository.findAllInvitationsBy(teacher!); await teacherInvitationRepository.findAllInvitationsBy(teacher!);
expect(invitations).toBeTruthy(); expect(invitations).toBeTruthy();
expect(invitations).toHaveLength(2); expect(invitations).toHaveLength(2);
}); });
it('should return all invitations for a teacher', async () => { it('should return all invitations for a teacher', async () => {
const teacher = await TeacherRepository.findByUsername('FooFighters'); const teacher = await teacherRepository.findByUsername('FooFighters');
const invitations = const invitations =
await TeacherInvitationRepository.findAllInvitationsFor(teacher!); await teacherInvitationRepository.findAllInvitationsFor(teacher!);
expect(invitations).toBeTruthy(); expect(invitations).toBeTruthy();
expect(invitations).toHaveLength(2); expect(invitations).toHaveLength(2);
}); });
it('should return all invitations for a class', async () => { it('should return all invitations for a class', async () => {
const class_ = await ClassRepository.findById('id02'); const class_ = await classRepository.findById('id02');
const invitations = const invitations =
await TeacherInvitationRepository.findAllInvitationsForClass( await teacherInvitationRepository.findAllInvitationsForClass(
class_! class_!
); );
@ -51,13 +51,13 @@ describe('ClassRepository', () => {
}); });
it('should not find a removed invitation', async () => { it('should not find a removed invitation', async () => {
const class_ = await ClassRepository.findById('id01'); const class_ = await classRepository.findById('id01');
const sender = await TeacherRepository.findByUsername('FooFighters'); const sender = await teacherRepository.findByUsername('FooFighters');
const receiver = await TeacherRepository.findByUsername('LimpBizkit'); const receiver = await teacherRepository.findByUsername('LimpBizkit');
await TeacherInvitationRepository.deleteBy(class_!, sender!, receiver!); await teacherInvitationRepository.deleteBy(class_!, sender!, receiver!);
const invitation = const invitation =
await TeacherInvitationRepository.findAllInvitationsBy(sender!); await teacherInvitationRepository.findAllInvitationsBy(sender!);
expect(invitation).toHaveLength(0); expect(invitation).toHaveLength(0);
}); });

View file

@ -8,21 +8,21 @@ const username = 'testteacher';
const firstName = 'John'; const firstName = 'John';
const lastName = 'Doe'; const lastName = 'Doe';
describe('TeacherRepository', () => { describe('TeacherRepository', () => {
let TeacherRepository: TeacherRepository; let teacherRepository: TeacherRepository;
beforeAll(async () => { beforeAll(async () => {
await setupTestApp(); await setupTestApp();
TeacherRepository = getTeacherRepository(); 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'); const teacher = await teacherRepository.findByUsername('test');
expect(teacher).toBeNull(); expect(teacher).toBeNull();
}); });
it('should return teacher from the datbase', async () => { it('should return teacher from the datbase', async () => {
const teacher = await TeacherRepository.findByUsername('FooFighters'); const teacher = await teacherRepository.findByUsername('FooFighters');
expect(teacher).toBeTruthy(); expect(teacher).toBeTruthy();
expect(teacher?.firstName).toBe('Dave'); expect(teacher?.firstName).toBe('Dave');
@ -30,22 +30,22 @@ describe('TeacherRepository', () => {
}); });
it('should return the queried teacher after he was added', async () => { it('should return the queried teacher after he was added', async () => {
await TeacherRepository.insert( await teacherRepository.insert(
new Teacher(username, firstName, lastName) new Teacher(username, firstName, lastName)
); );
const retrievedTeacher = const retrievedTeacher =
await TeacherRepository.findByUsername(username); await teacherRepository.findByUsername(username);
expect(retrievedTeacher).toBeTruthy(); expect(retrievedTeacher).toBeTruthy();
expect(retrievedTeacher?.firstName).toBe(firstName); expect(retrievedTeacher?.firstName).toBe(firstName);
expect(retrievedTeacher?.lastName).toBe(lastName); expect(retrievedTeacher?.lastName).toBe(lastName);
}); });
it('should no longer return the queried teacher after he was removed again', async () => { it('should no longer return the queried teacher after he was removed again', async () => {
await TeacherRepository.deleteByUsername('ZesdeMetaal'); await teacherRepository.deleteByUsername('ZesdeMetaal');
const retrievedTeacher = const retrievedTeacher =
await TeacherRepository.findByUsername('ZesdeMetaal'); await teacherRepository.findByUsername('ZesdeMetaal');
expect(retrievedTeacher).toBeNull(); expect(retrievedTeacher).toBeNull();
}); });
}); });