style: fix linting issues met Prettier

This commit is contained in:
Lint Action 2025-03-13 14:30:15 +00:00
parent e58835aa17
commit e73d5c21c3
34 changed files with 103 additions and 296 deletions

View file

@ -1,10 +1,7 @@
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 { getAssignmentRepository, getClassRepository } from '../../../src/data/repositories';
import { ClassRepository } from '../../../src/data/classes/class-repository';
describe('AssignmentRepository', () => {
@ -19,10 +16,7 @@ describe('AssignmentRepository', () => {
it('should return the requested assignment', async () => {
const class_ = await classRepository.findById('id02');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
2
);
const assignment = await assignmentRepository.findByClassAndId(class_!, 2);
expect(assignment).toBeTruthy();
expect(assignment!.title).toBe('tool');
@ -30,8 +24,7 @@ describe('AssignmentRepository', () => {
it('should return all assignments for a class', async () => {
const class_ = await classRepository.findById('id02');
const assignments =
await assignmentRepository.findAllAssignmentsInClass(class_!);
const assignments = await assignmentRepository.findAllAssignmentsInClass(class_!);
expect(assignments).toBeTruthy();
expect(assignments).toHaveLength(1);
@ -42,10 +35,7 @@ describe('AssignmentRepository', () => {
const class_ = await classRepository.findById('id01');
await assignmentRepository.deleteByClassAndId(class_!, 3);
const assignment = await assignmentRepository.findByClassAndId(
class_!,
3
);
const assignment = await assignmentRepository.findByClassAndId(class_!, 3);
expect(assignment).toBeNull();
});

View file

@ -1,11 +1,7 @@
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 { getAssignmentRepository, getClassRepository, getGroupRepository } from '../../../src/data/repositories';
import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository';
import { ClassRepository } from '../../../src/data/classes/class-repository';
@ -23,29 +19,18 @@ describe('GroupRepository', () => {
it('should return the requested group', async () => {
const class_ = await classRepository.findById('id01');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
1
);
const assignment = await assignmentRepository.findByClassAndId(class_!, 1);
const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!,
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 assignment = await assignmentRepository.findByClassAndId(class_!, 1);
const groups = await groupRepository.findAllGroupsForAssignment(
assignment!
);
const groups = await groupRepository.findAllGroupsForAssignment(assignment!);
expect(groups).toBeTruthy();
expect(groups).toHaveLength(3);
@ -53,17 +38,11 @@ describe('GroupRepository', () => {
it('should not find removed group', async () => {
const class_ = await classRepository.findById('id02');
const assignment = await assignmentRepository.findByClassAndId(
class_!,
2
);
const assignment = await assignmentRepository.findByClassAndId(class_!, 2);
await groupRepository.deleteByAssignmentAndGroupNumber(assignment!, 1);
const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!,
1
);
const group = await groupRepository.findByAssignmentAndGroupNumber(assignment!, 1);
expect(group).toBeNull();
});

View file

@ -33,11 +33,7 @@ describe('SubmissionRepository', () => {
it('should find the requested submission', async () => {
const id = new LearningObjectIdentifier('id03', Language.English, '1');
const submission =
await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(
id,
1
);
const submission = await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(id, 1);
expect(submission).toBeTruthy();
expect(submission?.content).toBe('sub1');
@ -46,11 +42,7 @@ 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 submission =
await submissionRepository.findMostRecentSubmissionForStudent(
id,
student!
);
const submission = await submissionRepository.findMostRecentSubmissionForStudent(id, student!);
expect(submission).toBeTruthy();
expect(submission?.submissionTime.getDate()).toBe(25);
@ -59,19 +51,9 @@ 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(
class_!,
1
);
const group = await groupRepository.findByAssignmentAndGroupNumber(
assignment!,
1
);
const submission =
await submissionRepository.findMostRecentSubmissionForGroup(
id,
group!
);
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);
@ -79,16 +61,9 @@ describe('SubmissionRepository', () => {
it('should not find a deleted submission', async () => {
const id = new LearningObjectIdentifier('id01', Language.English, '1');
await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(
id,
1
);
await submissionRepository.deleteSubmissionByLearningObjectAndSubmissionNumber(id, 1);
const submission =
await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(
id,
1
);
const submission = await submissionRepository.findSubmissionByLearningObjectAndSubmissionNumber(id, 1);
expect(submission).toBeNull();
});

View file

@ -1,11 +1,7 @@
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 { 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';
@ -25,9 +21,7 @@ describe('ClassJoinRequestRepository', () => {
it('should list all requests from student to join classes', async () => {
const student = await studentRepository.findByUsername('PinkFloyd');
const requests = await classJoinRequestRepository.findAllRequestsBy(
student!
);
const requests = await classJoinRequestRepository.findAllRequestsBy(student!);
expect(requests).toBeTruthy();
expect(requests).toHaveLength(2);
@ -35,23 +29,18 @@ describe('ClassJoinRequestRepository', () => {
it('should list all requests to a single class', async () => {
const class_ = await cassRepository.findById('id02');
const requests = await classJoinRequestRepository.findAllOpenRequestsTo(
class_!
);
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 student = await studentRepository.findByUsername('SmashingPumpkins');
const class_ = await cassRepository.findById('id03');
await classJoinRequestRepository.deleteBy(student!, class_!);
const request = await classJoinRequestRepository.findAllRequestsBy(
student!
);
const request = await classJoinRequestRepository.findAllRequestsBy(student!);
expect(request).toHaveLength(0);
});

View file

@ -1,10 +1,6 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import {
getClassRepository,
getTeacherInvitationRepository,
getTeacherRepository,
} from '../../../src/data/repositories';
import { getClassRepository, getTeacherInvitationRepository, getTeacherRepository } from '../../../src/data/repositories';
import { TeacherInvitationRepository } from '../../../src/data/classes/teacher-invitation-repository';
import { TeacherRepository } from '../../../src/data/users/teacher-repository';
import { ClassRepository } from '../../../src/data/classes/class-repository';
@ -23,8 +19,7 @@ describe('ClassRepository', () => {
it('should return all invitations from a teacher', async () => {
const teacher = await teacherRepository.findByUsername('LimpBizkit');
const invitations =
await teacherInvitationRepository.findAllInvitationsBy(teacher!);
const invitations = await teacherInvitationRepository.findAllInvitationsBy(teacher!);
expect(invitations).toBeTruthy();
expect(invitations).toHaveLength(2);
@ -32,8 +27,7 @@ describe('ClassRepository', () => {
it('should return all invitations for a teacher', async () => {
const teacher = await teacherRepository.findByUsername('FooFighters');
const invitations =
await teacherInvitationRepository.findAllInvitationsFor(teacher!);
const invitations = await teacherInvitationRepository.findAllInvitationsFor(teacher!);
expect(invitations).toBeTruthy();
expect(invitations).toHaveLength(2);
@ -41,10 +35,7 @@ describe('ClassRepository', () => {
it('should return all invitations for a class', async () => {
const class_ = await classRepository.findById('id02');
const invitations =
await teacherInvitationRepository.findAllInvitationsForClass(
class_!
);
const invitations = await teacherInvitationRepository.findAllInvitationsForClass(class_!);
expect(invitations).toBeTruthy();
expect(invitations).toHaveLength(2);
@ -56,8 +47,7 @@ describe('ClassRepository', () => {
const receiver = await teacherRepository.findByUsername('LimpBizkit');
await teacherInvitationRepository.deleteBy(class_!, sender!, receiver!);
const invitation =
await teacherInvitationRepository.findAllInvitationsBy(sender!);
const invitation = await teacherInvitationRepository.findAllInvitationsBy(sender!);
expect(invitation).toHaveLength(0);
});

View file

@ -1,9 +1,6 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests.js';
import {
getAttachmentRepository,
getLearningObjectRepository,
} from '../../../src/data/repositories.js';
import { getAttachmentRepository, getLearningObjectRepository } from '../../../src/data/repositories.js';
import { AttachmentRepository } from '../../../src/data/content/attachment-repository.js';
import { LearningObjectRepository } from '../../../src/data/content/learning-object-repository.js';
import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier.js';
@ -21,15 +18,13 @@ describe('AttachmentRepository', () => {
it('should return the requested attachment', async () => {
const id = new LearningObjectIdentifier('id02', Language.English, '1');
const learningObject =
await learningObjectRepository.findByIdentifier(id);
const learningObject = await learningObjectRepository.findByIdentifier(id);
const attachment =
await attachmentRepository.findByMostRecentVersionOfLearningObjectAndName(
learningObject!,
Language.English,
'attachment01'
);
const attachment = await attachmentRepository.findByMostRecentVersionOfLearningObjectAndName(
learningObject!,
Language.English,
'attachment01'
);
expect(attachment).toBeTruthy();
});

View file

@ -17,8 +17,7 @@ describe('LearningObjectRepository', () => {
const id02 = new LearningObjectIdentifier('test_id', Language.English, '1');
it('should return the learning object that matches identifier 1', async () => {
const learningObject =
await learningObjectRepository.findByIdentifier(id01);
const learningObject = await learningObjectRepository.findByIdentifier(id01);
expect(learningObject).toBeTruthy();
expect(learningObject?.title).toBe('Undertow');
@ -26,8 +25,7 @@ describe('LearningObjectRepository', () => {
});
it('should return nothing because the identifier does not exist in the database', async () => {
const learningObject =
await learningObjectRepository.findByIdentifier(id02);
const learningObject = await learningObjectRepository.findByIdentifier(id02);
expect(learningObject).toBeNull();
});

View file

@ -13,21 +13,13 @@ describe('LearningPathRepository', () => {
});
it('should return nothing because no match for hruid and language', async () => {
const learningPath =
await learningPathRepository.findByHruidAndLanguage(
'test_id',
Language.Dutch
);
const learningPath = await learningPathRepository.findByHruidAndLanguage('test_id', Language.Dutch);
expect(learningPath).toBeNull();
});
it('should return requested learning path', async () => {
const learningPath =
await learningPathRepository.findByHruidAndLanguage(
'id01',
Language.English
);
const learningPath = await learningPathRepository.findByHruidAndLanguage('id01', Language.English);
expect(learningPath).toBeTruthy();
expect(learningPath?.title).toBe('repertoire Tool');

View file

@ -1,11 +1,7 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { AnswerRepository } from '../../../src/data/questions/answer-repository';
import {
getAnswerRepository,
getQuestionRepository,
getTeacherRepository,
} from '../../../src/data/repositories';
import { getAnswerRepository, getQuestionRepository, getTeacherRepository } from '../../../src/data/repositories';
import { QuestionRepository } from '../../../src/data/questions/question-repository';
import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier';
import { Language } from '../../../src/entities/content/language';
@ -25,13 +21,11 @@ describe('AnswerRepository', () => {
it('should find all answers to a question', async () => {
const id = new LearningObjectIdentifier('id05', Language.English, '1');
const questions =
await questionRepository.findAllQuestionsAboutLearningObject(id);
const questions = await questionRepository.findAllQuestionsAboutLearningObject(id);
const question = questions.filter((it) => it.sequenceNumber == 2)[0];
const answers =
await answerRepository.findAllAnswersToQuestion(question);
const answers = await answerRepository.findAllAnswersToQuestion(question);
expect(answers).toBeTruthy();
expect(answers).toHaveLength(2);
@ -42,8 +36,7 @@ describe('AnswerRepository', () => {
it('should create an answer to a question', async () => {
const teacher = await teacherRepository.findByUsername('FooFighters');
const id = new LearningObjectIdentifier('id05', Language.English, '1');
const questions =
await questionRepository.findAllQuestionsAboutLearningObject(id);
const questions = await questionRepository.findAllQuestionsAboutLearningObject(id);
const question = questions[0];
@ -53,8 +46,7 @@ describe('AnswerRepository', () => {
content: 'created answer',
});
const answers =
await answerRepository.findAllAnswersToQuestion(question);
const answers = await answerRepository.findAllAnswersToQuestion(question);
expect(answers).toBeTruthy();
expect(answers).toHaveLength(1);
@ -63,17 +55,11 @@ describe('AnswerRepository', () => {
it('should not find a removed answer', async () => {
const id = new LearningObjectIdentifier('id04', Language.English, '1');
const questions =
await questionRepository.findAllQuestionsAboutLearningObject(id);
const questions = await questionRepository.findAllQuestionsAboutLearningObject(id);
await answerRepository.removeAnswerByQuestionAndSequenceNumber(
questions[0],
1
);
await answerRepository.removeAnswerByQuestionAndSequenceNumber(questions[0], 1);
const emptyList = await answerRepository.findAllAnswersToQuestion(
questions[0]
);
const emptyList = await answerRepository.findAllAnswersToQuestion(questions[0]);
expect(emptyList).toHaveLength(0);
});

View file

@ -1,11 +1,7 @@
import { beforeAll, describe, expect, it } from 'vitest';
import { setupTestApp } from '../../setup-tests';
import { QuestionRepository } from '../../../src/data/questions/question-repository';
import {
getLearningObjectRepository,
getQuestionRepository,
getStudentRepository,
} from '../../../src/data/repositories';
import { getLearningObjectRepository, getQuestionRepository, getStudentRepository } from '../../../src/data/repositories';
import { StudentRepository } from '../../../src/data/users/student-repository';
import { LearningObjectRepository } from '../../../src/data/content/learning-object-repository';
import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier';
@ -25,8 +21,7 @@ describe('QuestionRepository', () => {
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);
const questions = await questionRepository.findAllQuestionsAboutLearningObject(id);
expect(questions).toBeTruthy();
expect(questions).toHaveLength(2);
@ -40,8 +35,7 @@ describe('QuestionRepository', () => {
author: student!,
content: 'question?',
});
const question =
await questionRepository.findAllQuestionsAboutLearningObject(id);
const question = await questionRepository.findAllQuestionsAboutLearningObject(id);
expect(question).toBeTruthy();
expect(question).toHaveLength(1);
@ -49,13 +43,9 @@ describe('QuestionRepository', () => {
it('should not find removed question', async () => {
const id = new LearningObjectIdentifier('id04', Language.English, '1');
await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(
id,
1
);
await questionRepository.removeQuestionByLearningObjectAndSequenceNumber(id, 1);
const question =
await questionRepository.findAllQuestionsAboutLearningObject(id);
const question = await questionRepository.findAllQuestionsAboutLearningObject(id);
expect(question).toHaveLength(0);
});

View file

@ -30,12 +30,9 @@ describe('TeacherRepository', () => {
});
it('should return the queried teacher after he was added', async () => {
await teacherRepository.insert(
new Teacher(username, firstName, lastName)
);
await teacherRepository.insert(new Teacher(username, firstName, lastName));
const retrievedTeacher =
await teacherRepository.findByUsername(username);
const retrievedTeacher = await teacherRepository.findByUsername(username);
expect(retrievedTeacher).toBeTruthy();
expect(retrievedTeacher?.firstName).toBe(firstName);
expect(retrievedTeacher?.lastName).toBe(lastName);
@ -44,8 +41,7 @@ describe('TeacherRepository', () => {
it('should no longer return the queried teacher after he was removed again', async () => {
await teacherRepository.deleteByUsername('ZesdeMetaal');
const retrievedTeacher =
await teacherRepository.findByUsername('ZesdeMetaal');
const retrievedTeacher = await teacherRepository.findByUsername('ZesdeMetaal');
expect(retrievedTeacher).toBeNull();
});
});