style: verander namen van variabelen zodat ze beginnen met een kleine letter
This commit is contained in:
parent
4aa2dfc7d3
commit
da8e27acfd
12 changed files with 125 additions and 125 deletions
|
@ -13,21 +13,21 @@ import { Question } from '../../src/entities/questions/question.entity';
|
|||
import { TeacherRepository } from '../../src/data/users/teacher-repository';
|
||||
|
||||
describe('AnswerRepository', () => {
|
||||
let AnswerRepository: AnswerRepository;
|
||||
let QuestionRepository: QuestionRepository;
|
||||
let TeacherRepository: TeacherRepository;
|
||||
let answerRepository: AnswerRepository;
|
||||
let questionRepository: QuestionRepository;
|
||||
let teacherRepository: TeacherRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
AnswerRepository = getAnswerRepository();
|
||||
QuestionRepository = getQuestionRepository();
|
||||
TeacherRepository = getTeacherRepository();
|
||||
answerRepository = getAnswerRepository();
|
||||
questionRepository = getQuestionRepository();
|
||||
teacherRepository = getTeacherRepository();
|
||||
});
|
||||
|
||||
it('should find all answers to a question', async () => {
|
||||
const id = new LearningObjectIdentifier('id05', Language.English, '1');
|
||||
const questions =
|
||||
await QuestionRepository.findAllQuestionsAboutLearningObject(id);
|
||||
await questionRepository.findAllQuestionsAboutLearningObject(id);
|
||||
let question: Question;
|
||||
if (questions[0].sequenceNumber == 2) {
|
||||
question = questions[0];
|
||||
|
@ -35,7 +35,7 @@ describe('AnswerRepository', () => {
|
|||
question = questions[1];
|
||||
}
|
||||
const answers =
|
||||
await AnswerRepository.findAllAnswersToQuestion(question);
|
||||
await answerRepository.findAllAnswersToQuestion(question);
|
||||
|
||||
expect(answers).toBeTruthy();
|
||||
expect(answers).toHaveLength(2);
|
||||
|
@ -69,14 +69,14 @@ describe('AnswerRepository', () => {
|
|||
it('should not find a removed answer', async () => {
|
||||
const id = new LearningObjectIdentifier('id04', Language.English, '1');
|
||||
const questions =
|
||||
await QuestionRepository.findAllQuestionsAboutLearningObject(id);
|
||||
await questionRepository.findAllQuestionsAboutLearningObject(id);
|
||||
|
||||
await AnswerRepository.removeAnswerByQuestionAndSequenceNumber(
|
||||
await answerRepository.removeAnswerByQuestionAndSequenceNumber(
|
||||
questions[0],
|
||||
1
|
||||
);
|
||||
|
||||
const emptyList = await AnswerRepository.findAllAnswersToQuestion(
|
||||
const emptyList = await answerRepository.findAllAnswersToQuestion(
|
||||
questions[0]
|
||||
);
|
||||
|
||||
|
|
|
@ -8,18 +8,18 @@ import {
|
|||
import { ClassRepository } from '../../src/data/classes/class-repository';
|
||||
|
||||
describe('AssignmentRepository', () => {
|
||||
let AssignmentRepository: AssignmentRepository;
|
||||
let ClassRepository: ClassRepository;
|
||||
let assignmentRepository: AssignmentRepository;
|
||||
let classRepository: ClassRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
AssignmentRepository = getAssignmentRepository();
|
||||
ClassRepository = getClassRepository();
|
||||
assignmentRepository = getAssignmentRepository();
|
||||
classRepository = getClassRepository();
|
||||
});
|
||||
|
||||
it('should return the requested assignment', async () => {
|
||||
const class_ = await ClassRepository.findById('id02');
|
||||
const assignment = await AssignmentRepository.findByClassAndId(
|
||||
const class_ = await classRepository.findById('id02');
|
||||
const assignment = await assignmentRepository.findByClassAndId(
|
||||
class_!,
|
||||
2
|
||||
);
|
||||
|
@ -29,19 +29,19 @@ describe('AssignmentRepository', () => {
|
|||
});
|
||||
|
||||
it('should return all assignments for a class', async () => {
|
||||
const class_ = await ClassRepository.findById('id02');
|
||||
const class_ = await classRepository.findById('id02');
|
||||
const assignments =
|
||||
await AssignmentRepository.findAllAssignmentsInClass(class_!);
|
||||
await assignmentRepository.findAllAssignmentsInClass(class_!);
|
||||
|
||||
expect(assignments).toBeTruthy();
|
||||
expect(assignments).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('should not find removed assignment', async () => {
|
||||
const class_ = await ClassRepository.findById('id01');
|
||||
await AssignmentRepository.deleteByClassAndId(class_!, 3);
|
||||
const class_ = await classRepository.findById('id01');
|
||||
await assignmentRepository.deleteByClassAndId(class_!, 3);
|
||||
|
||||
const assignment = await AssignmentRepository.findByClassAndId(
|
||||
const assignment = await assignmentRepository.findByClassAndId(
|
||||
class_!,
|
||||
3
|
||||
);
|
||||
|
|
|
@ -10,22 +10,22 @@ import { LearningObjectIdentifier } from '../../src/entities/content/learning-ob
|
|||
import { Language } from '../../src/entities/content/language';
|
||||
|
||||
describe('AttachmentRepository', () => {
|
||||
let AttachmentRepository: AttachmentRepository;
|
||||
let LearningObjectRepository: LearningObjectRepository;
|
||||
let attachmentRepository: AttachmentRepository;
|
||||
let learningObjectRepository: LearningObjectRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
AttachmentRepository = getAttachmentRepository();
|
||||
LearningObjectRepository = getLearningObjectRepository();
|
||||
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);
|
||||
await learningObjectRepository.findByIdentifier(id);
|
||||
|
||||
const attachment =
|
||||
await AttachmentRepository.findByLearningObjectAndNumber(
|
||||
await attachmentRepository.findByLearningObjectAndNumber(
|
||||
learningObject!,
|
||||
1
|
||||
);
|
||||
|
|
|
@ -12,20 +12,20 @@ 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 ClassRepository: ClassRepository;
|
||||
let classJoinRequestRepository: ClassJoinRequestRepository;
|
||||
let studentRepository: StudentRepository;
|
||||
let cassRepository: ClassRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
ClassJoinRequestRepository = getClassJoinRequestRepository();
|
||||
StudentRepository = getStudentRepository();
|
||||
ClassRepository = getClassRepository();
|
||||
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(
|
||||
const student = await studentRepository.findByUsername('PinkFloyd');
|
||||
const requests = await classJoinRequestRepository.findAllRequestsBy(
|
||||
student!
|
||||
);
|
||||
|
||||
|
@ -34,8 +34,8 @@ describe('ClassJoinRequestRepository', () => {
|
|||
});
|
||||
|
||||
it('should list all requests to a single class', async () => {
|
||||
const class_ = await ClassRepository.findById('id02');
|
||||
const requests = await ClassJoinRequestRepository.findAllOpenRequestsTo(
|
||||
const class_ = await cassRepository.findById('id02');
|
||||
const requests = await classJoinRequestRepository.findAllOpenRequestsTo(
|
||||
class_!
|
||||
);
|
||||
|
||||
|
@ -45,11 +45,11 @@ describe('ClassJoinRequestRepository', () => {
|
|||
|
||||
it('should not find a removed request', async () => {
|
||||
const student =
|
||||
await StudentRepository.findByUsername('SmashingPumpkins');
|
||||
const class_ = await ClassRepository.findById('id03');
|
||||
await ClassJoinRequestRepository.deleteBy(student!, class_!);
|
||||
await studentRepository.findByUsername('SmashingPumpkins');
|
||||
const class_ = await cassRepository.findById('id03');
|
||||
await classJoinRequestRepository.deleteBy(student!, class_!);
|
||||
|
||||
const request = await ClassJoinRequestRepository.findAllRequestsBy(
|
||||
const request = await classJoinRequestRepository.findAllRequestsBy(
|
||||
student!
|
||||
);
|
||||
|
||||
|
|
|
@ -4,30 +4,30 @@ import { setupTestApp } from '../setup-tests';
|
|||
import { getClassRepository } from '../../src/data/repositories';
|
||||
|
||||
describe('ClassRepository', () => {
|
||||
let ClassRepository: ClassRepository;
|
||||
let classRepository: ClassRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
ClassRepository = getClassRepository();
|
||||
classRepository = getClassRepository();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
it('should return requested class', async () => {
|
||||
const classVar = await ClassRepository.findById('id01');
|
||||
const classVar = await classRepository.findById('id01');
|
||||
|
||||
expect(classVar).toBeTruthy();
|
||||
expect(classVar?.displayName).toBe('class01');
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
|
|
@ -11,25 +11,25 @@ import { ClassRepository } from '../../src/data/classes/class-repository';
|
|||
import { Class } from '../../src/entities/classes/class.entity';
|
||||
|
||||
describe('GroupRepository', () => {
|
||||
let GroupRepository: GroupRepository;
|
||||
let AssignmentRepository: AssignmentRepository;
|
||||
let ClassRepository: ClassRepository;
|
||||
let groupRepository: GroupRepository;
|
||||
let assignmentRepository: AssignmentRepository;
|
||||
let classRepository: ClassRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
GroupRepository = getGroupRepository();
|
||||
AssignmentRepository = getAssignmentRepository();
|
||||
ClassRepository = getClassRepository();
|
||||
groupRepository = getGroupRepository();
|
||||
assignmentRepository = getAssignmentRepository();
|
||||
classRepository = getClassRepository();
|
||||
});
|
||||
|
||||
it('should return the requested group', async () => {
|
||||
const class_ = await ClassRepository.findById('id01');
|
||||
const assignment = await AssignmentRepository.findByClassAndId(
|
||||
const class_ = await classRepository.findById('id01');
|
||||
const assignment = await assignmentRepository.findByClassAndId(
|
||||
class_!,
|
||||
1
|
||||
);
|
||||
|
||||
const group = await GroupRepository.findByAssignmentAndGroupNumber(
|
||||
const group = await groupRepository.findByAssignmentAndGroupNumber(
|
||||
assignment!,
|
||||
1
|
||||
);
|
||||
|
@ -38,13 +38,13 @@ describe('GroupRepository', () => {
|
|||
});
|
||||
|
||||
it('should return all groups for assignment', async () => {
|
||||
const class_ = await ClassRepository.findById('id01');
|
||||
const assignment = await AssignmentRepository.findByClassAndId(
|
||||
const class_ = await classRepository.findById('id01');
|
||||
const assignment = await assignmentRepository.findByClassAndId(
|
||||
class_!,
|
||||
1
|
||||
);
|
||||
|
||||
const groups = await GroupRepository.findAllGroupsForAssignment(
|
||||
const groups = await groupRepository.findAllGroupsForAssignment(
|
||||
assignment!
|
||||
);
|
||||
|
||||
|
@ -53,15 +53,15 @@ describe('GroupRepository', () => {
|
|||
});
|
||||
|
||||
it('should not find removed group', async () => {
|
||||
const class_ = await ClassRepository.findById('id02');
|
||||
const assignment = await AssignmentRepository.findByClassAndId(
|
||||
const class_ = await classRepository.findById('id02');
|
||||
const assignment = await assignmentRepository.findByClassAndId(
|
||||
class_!,
|
||||
2
|
||||
);
|
||||
|
||||
await GroupRepository.deleteByAssignmentAndGroupNumber(assignment!, 1);
|
||||
await groupRepository.deleteByAssignmentAndGroupNumber(assignment!, 1);
|
||||
|
||||
const group = await GroupRepository.findByAssignmentAndGroupNumber(
|
||||
const group = await groupRepository.findByAssignmentAndGroupNumber(
|
||||
assignment!,
|
||||
1
|
||||
);
|
||||
|
|
|
@ -6,11 +6,11 @@ import { LearningObjectIdentifier } from '../../src/entities/content/learning-ob
|
|||
import { Language } from '../../src/entities/content/language';
|
||||
|
||||
describe('LearningObjectRepository', () => {
|
||||
let LearningObjectRepository: LearningObjectRepository;
|
||||
let learningObjectRepository: LearningObjectRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
LearningObjectRepository = getLearningObjectRepository();
|
||||
learningObjectRepository = getLearningObjectRepository();
|
||||
});
|
||||
|
||||
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 () => {
|
||||
const learningObject =
|
||||
await LearningObjectRepository.findByIdentifier(id01);
|
||||
await learningObjectRepository.findByIdentifier(id01);
|
||||
|
||||
expect(learningObject).toBeTruthy();
|
||||
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 () => {
|
||||
const learningObject =
|
||||
await LearningObjectRepository.findByIdentifier(id02);
|
||||
await learningObjectRepository.findByIdentifier(id02);
|
||||
|
||||
expect(learningObject).toBeNull();
|
||||
});
|
||||
|
|
|
@ -5,16 +5,16 @@ import { setupTestApp } from '../setup-tests';
|
|||
import { Language } from '../../src/entities/content/language';
|
||||
|
||||
describe('LearningPathRepository', () => {
|
||||
let LearningPathRepository: LearningPathRepository;
|
||||
let learningPathRepository: LearningPathRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
LearningPathRepository = getLearningPathRepository();
|
||||
learningPathRepository = getLearningPathRepository();
|
||||
});
|
||||
|
||||
it('should return nothing because no match for hruid and language', async () => {
|
||||
const learningPath =
|
||||
await LearningPathRepository.findByHruidAndLanguage(
|
||||
await learningPathRepository.findByHruidAndLanguage(
|
||||
'test_id',
|
||||
Language.Dutch
|
||||
);
|
||||
|
@ -24,7 +24,7 @@ describe('LearningPathRepository', () => {
|
|||
|
||||
it('should return requested learning path', async () => {
|
||||
const learningPath =
|
||||
await LearningPathRepository.findByHruidAndLanguage(
|
||||
await learningPathRepository.findByHruidAndLanguage(
|
||||
'id01',
|
||||
Language.English
|
||||
);
|
||||
|
|
|
@ -13,21 +13,21 @@ import { Language } from '../../src/entities/content/language';
|
|||
import { Question } from '../../src/entities/questions/question.entity';
|
||||
|
||||
describe('QuestionRepository', () => {
|
||||
let QuestionRepository: QuestionRepository;
|
||||
let StudentRepository: StudentRepository;
|
||||
let LearningObjectRepository: LearningObjectRepository;
|
||||
let questionRepository: QuestionRepository;
|
||||
let studentRepository: StudentRepository;
|
||||
let learningObjectRepository: LearningObjectRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
QuestionRepository = getQuestionRepository();
|
||||
StudentRepository = getStudentRepository();
|
||||
LearningObjectRepository = getLearningObjectRepository();
|
||||
questionRepository = getQuestionRepository();
|
||||
studentRepository = getStudentRepository();
|
||||
learningObjectRepository = getLearningObjectRepository();
|
||||
});
|
||||
|
||||
it('should return all questions part of the given learning object', async () => {
|
||||
const id = new LearningObjectIdentifier('id05', Language.English, '1');
|
||||
const questions =
|
||||
await QuestionRepository.findAllQuestionsAboutLearningObject(id);
|
||||
await questionRepository.findAllQuestionsAboutLearningObject(id);
|
||||
|
||||
expect(questions).toBeTruthy();
|
||||
expect(questions).toHaveLength(2);
|
||||
|
@ -50,13 +50,13 @@ describe('QuestionRepository', () => {
|
|||
|
||||
it('should not find removed question', async () => {
|
||||
const id = new LearningObjectIdentifier('id04', Language.English, '1');
|
||||
await QuestionRepository.removeQuestionByLearningObjectAndSequenceNumber(
|
||||
await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(
|
||||
id,
|
||||
1
|
||||
);
|
||||
|
||||
const question =
|
||||
await QuestionRepository.findAllQuestionsAboutLearningObject(id);
|
||||
await questionRepository.findAllQuestionsAboutLearningObject(id);
|
||||
|
||||
expect(question).toHaveLength(0);
|
||||
});
|
||||
|
|
|
@ -19,25 +19,25 @@ import { AssignmentRepository } from '../../src/data/assignments/assignment-repo
|
|||
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;
|
||||
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();
|
||||
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(
|
||||
await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(
|
||||
id,
|
||||
1
|
||||
);
|
||||
|
@ -48,9 +48,9 @@ describe('SubmissionRepository', () => {
|
|||
|
||||
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 student = await studentRepository.findByUsername('Noordkaap');
|
||||
const submission =
|
||||
await SubmissionRepository.findMostRecentSubmissionForStudent(
|
||||
await submissionRepository.findMostRecentSubmissionForStudent(
|
||||
id,
|
||||
student!
|
||||
);
|
||||
|
@ -61,17 +61,17 @@ describe('SubmissionRepository', () => {
|
|||
|
||||
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(
|
||||
const class_ = await classRepository.findById('id01');
|
||||
const assignment = await assignmentRepository.findByClassAndId(
|
||||
class_!,
|
||||
1
|
||||
);
|
||||
const group = await GroupRepository.findByAssignmentAndGroupNumber(
|
||||
const group = await groupRepository.findByAssignmentAndGroupNumber(
|
||||
assignment!,
|
||||
1
|
||||
);
|
||||
const submission =
|
||||
await SubmissionRepository.findMostRecentSubmissionForGroup(
|
||||
await submissionRepository.findMostRecentSubmissionForGroup(
|
||||
id,
|
||||
group!
|
||||
);
|
||||
|
@ -82,13 +82,13 @@ describe('SubmissionRepository', () => {
|
|||
|
||||
it('should not find a deleted submission', async () => {
|
||||
const id = new LearningObjectIdentifier('id01', Language.English, '1');
|
||||
await SubmissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(
|
||||
await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(
|
||||
id,
|
||||
1
|
||||
);
|
||||
|
||||
const submission =
|
||||
await SubmissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(
|
||||
await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(
|
||||
id,
|
||||
1
|
||||
);
|
||||
|
|
|
@ -10,39 +10,39 @@ import { TeacherRepository } from '../../src/data/users/teacher-repository';
|
|||
import { ClassRepository } from '../../src/data/classes/class-repository';
|
||||
|
||||
describe('ClassRepository', () => {
|
||||
let TeacherInvitationRepository: TeacherInvitationRepository;
|
||||
let TeacherRepository: TeacherRepository;
|
||||
let ClassRepository: ClassRepository;
|
||||
let teacherInvitationRepository: TeacherInvitationRepository;
|
||||
let teacherRepository: TeacherRepository;
|
||||
let classRepository: ClassRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
TeacherInvitationRepository = getTeacherInvitationRepository();
|
||||
TeacherRepository = getTeacherRepository();
|
||||
ClassRepository = getClassRepository();
|
||||
teacherInvitationRepository = getTeacherInvitationRepository();
|
||||
teacherRepository = getTeacherRepository();
|
||||
classRepository = getClassRepository();
|
||||
});
|
||||
|
||||
it('should return all invitations from a teacher', async () => {
|
||||
const teacher = await TeacherRepository.findByUsername('LimpBizkit');
|
||||
const teacher = await teacherRepository.findByUsername('LimpBizkit');
|
||||
const invitations =
|
||||
await TeacherInvitationRepository.findAllInvitationsBy(teacher!);
|
||||
await teacherInvitationRepository.findAllInvitationsBy(teacher!);
|
||||
|
||||
expect(invitations).toBeTruthy();
|
||||
expect(invitations).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('should return all invitations for a teacher', async () => {
|
||||
const teacher = await TeacherRepository.findByUsername('FooFighters');
|
||||
const teacher = await teacherRepository.findByUsername('FooFighters');
|
||||
const invitations =
|
||||
await TeacherInvitationRepository.findAllInvitationsFor(teacher!);
|
||||
await teacherInvitationRepository.findAllInvitationsFor(teacher!);
|
||||
|
||||
expect(invitations).toBeTruthy();
|
||||
expect(invitations).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('should return all invitations for a class', async () => {
|
||||
const class_ = await ClassRepository.findById('id02');
|
||||
const class_ = await classRepository.findById('id02');
|
||||
const invitations =
|
||||
await TeacherInvitationRepository.findAllInvitationsForClass(
|
||||
await teacherInvitationRepository.findAllInvitationsForClass(
|
||||
class_!
|
||||
);
|
||||
|
||||
|
@ -51,13 +51,13 @@ describe('ClassRepository', () => {
|
|||
});
|
||||
|
||||
it('should not find a removed invitation', async () => {
|
||||
const class_ = await ClassRepository.findById('id01');
|
||||
const sender = await TeacherRepository.findByUsername('FooFighters');
|
||||
const receiver = await TeacherRepository.findByUsername('LimpBizkit');
|
||||
await TeacherInvitationRepository.deleteBy(class_!, sender!, receiver!);
|
||||
const class_ = await classRepository.findById('id01');
|
||||
const sender = await teacherRepository.findByUsername('FooFighters');
|
||||
const receiver = await teacherRepository.findByUsername('LimpBizkit');
|
||||
await teacherInvitationRepository.deleteBy(class_!, sender!, receiver!);
|
||||
|
||||
const invitation =
|
||||
await TeacherInvitationRepository.findAllInvitationsBy(sender!);
|
||||
await teacherInvitationRepository.findAllInvitationsBy(sender!);
|
||||
|
||||
expect(invitation).toHaveLength(0);
|
||||
});
|
||||
|
|
|
@ -8,21 +8,21 @@ const username = 'testteacher';
|
|||
const firstName = 'John';
|
||||
const lastName = 'Doe';
|
||||
describe('TeacherRepository', () => {
|
||||
let TeacherRepository: TeacherRepository;
|
||||
let teacherRepository: TeacherRepository;
|
||||
|
||||
beforeAll(async () => {
|
||||
await setupTestApp();
|
||||
TeacherRepository = getTeacherRepository();
|
||||
teacherRepository = getTeacherRepository();
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
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?.firstName).toBe('Dave');
|
||||
|
@ -30,22 +30,22 @@ describe('TeacherRepository', () => {
|
|||
});
|
||||
|
||||
it('should return the queried teacher after he was added', async () => {
|
||||
await TeacherRepository.insert(
|
||||
await teacherRepository.insert(
|
||||
new Teacher(username, firstName, lastName)
|
||||
);
|
||||
|
||||
const retrievedTeacher =
|
||||
await TeacherRepository.findByUsername(username);
|
||||
await teacherRepository.findByUsername(username);
|
||||
expect(retrievedTeacher).toBeTruthy();
|
||||
expect(retrievedTeacher?.firstName).toBe(firstName);
|
||||
expect(retrievedTeacher?.lastName).toBe(lastName);
|
||||
});
|
||||
|
||||
it('should no longer return the queried teacher after he was removed again', async () => {
|
||||
await TeacherRepository.deleteByUsername('ZesdeMetaal');
|
||||
await teacherRepository.deleteByUsername('ZesdeMetaal');
|
||||
|
||||
const retrievedTeacher =
|
||||
await TeacherRepository.findByUsername('ZesdeMetaal');
|
||||
await teacherRepository.findByUsername('ZesdeMetaal');
|
||||
expect(retrievedTeacher).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue