style: format en linting
This commit is contained in:
		
							parent
							
								
									4cb1469479
								
							
						
					
					
						commit
						e2bf413f35
					
				
					 22 changed files with 41 additions and 71 deletions
				
			
		|  | @ -17,7 +17,7 @@ export async function initORM(testingMode = false): Promise<MikroORM<IDatabaseDr | ||||||
| 
 | 
 | ||||||
|     // Update the database scheme if necessary and enabled.
 |     // Update the database scheme if necessary and enabled.
 | ||||||
|     if (getEnvVar(envVars.DbUpdate)) { |     if (getEnvVar(envVars.DbUpdate)) { | ||||||
|         logger.info("MikroORM: Updating database schema"); |         logger.info('MikroORM: Updating database schema'); | ||||||
|         await orm.schema.updateSchema(); |         await orm.schema.updateSchema(); | ||||||
|     } else { |     } else { | ||||||
|         const diff = await orm.schema.getUpdateSchemaSQL(); |         const diff = await orm.schema.getUpdateSchemaSQL(); | ||||||
|  |  | ||||||
|  | @ -5,7 +5,6 @@ import { Language } from '@dwengo-1/common/util/language'; | ||||||
| import { getAllAnswersHandler, getAnswerHandler, updateAnswerHandler } from '../../src/controllers/answers'; | import { getAllAnswersHandler, getAnswerHandler, updateAnswerHandler } from '../../src/controllers/answers'; | ||||||
| import { BadRequestException } from '../../src/exceptions/bad-request-exception'; | import { BadRequestException } from '../../src/exceptions/bad-request-exception'; | ||||||
| import { NotFoundException } from '../../src/exceptions/not-found-exception'; | import { NotFoundException } from '../../src/exceptions/not-found-exception'; | ||||||
| import { getQuestion02 } from '../test_assets/questions/questions.testdata'; |  | ||||||
| import { getAnswer02 } from '../test_assets/questions/answers.testdata'; | import { getAnswer02 } from '../test_assets/questions/answers.testdata'; | ||||||
| 
 | 
 | ||||||
| describe('Questions controllers', () => { | describe('Questions controllers', () => { | ||||||
|  |  | ||||||
|  | @ -15,7 +15,7 @@ import { | ||||||
|     deleteClassJoinRequestHandler, |     deleteClassJoinRequestHandler, | ||||||
|     getStudentRequestHandler, |     getStudentRequestHandler, | ||||||
| } from '../../src/controllers/students.js'; | } from '../../src/controllers/students.js'; | ||||||
| import { getDireStraits, getNoordkaap, getPinkFloyd, getTheDoors, TEST_STUDENTS } from '../test_assets/users/students.testdata.js'; | import { getDireStraits, getNoordkaap, getTheDoors, TEST_STUDENTS } from '../test_assets/users/students.testdata.js'; | ||||||
| import { NotFoundException } from '../../src/exceptions/not-found-exception.js'; | import { NotFoundException } from '../../src/exceptions/not-found-exception.js'; | ||||||
| import { BadRequestException } from '../../src/exceptions/bad-request-exception.js'; | import { BadRequestException } from '../../src/exceptions/bad-request-exception.js'; | ||||||
| import { ConflictException } from '../../src/exceptions/conflict-exception.js'; | import { ConflictException } from '../../src/exceptions/conflict-exception.js'; | ||||||
|  | @ -25,7 +25,6 @@ import { getClass02 } from '../test_assets/classes/classes.testdata.js'; | ||||||
| import { getClassJoinRequest02 } from '../test_assets/classes/class-join-requests.testdata.js'; | import { getClassJoinRequest02 } from '../test_assets/classes/class-join-requests.testdata.js'; | ||||||
| import { getTestGroup01 } from '../test_assets/assignments/groups.testdata.js'; | import { getTestGroup01 } from '../test_assets/assignments/groups.testdata.js'; | ||||||
| import { getSubmission01 } from '../test_assets/assignments/submission.testdata.js'; | import { getSubmission01 } from '../test_assets/assignments/submission.testdata.js'; | ||||||
| import { getQuestion } from '../../src/services/questions.js'; |  | ||||||
| import { getQuestion01 } from '../test_assets/questions/questions.testdata.js'; | import { getQuestion01 } from '../test_assets/questions/questions.testdata.js'; | ||||||
| 
 | 
 | ||||||
| describe('Student controllers', () => { | describe('Student controllers', () => { | ||||||
|  |  | ||||||
|  | @ -14,7 +14,6 @@ import { BadRequestException } from '../../src/exceptions/bad-request-exception' | ||||||
| import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | import { ClassStatus } from '@dwengo-1/common/util/class-join-request'; | ||||||
| import { getTeacherInvitation01 } from '../test_assets/classes/teacher-invitations.testdata.js'; | import { getTeacherInvitation01 } from '../test_assets/classes/teacher-invitations.testdata.js'; | ||||||
| import { getLimpBizkit, getTestleerkracht1 } from '../test_assets/users/teachers.testdata.js'; | import { getLimpBizkit, getTestleerkracht1 } from '../test_assets/users/teachers.testdata.js'; | ||||||
| import { getTestGroup01 } from '../test_assets/assignments/groups.testdata.js'; |  | ||||||
| import { getClass02 } from '../test_assets/classes/classes.testdata.js'; | import { getClass02 } from '../test_assets/classes/classes.testdata.js'; | ||||||
| 
 | 
 | ||||||
| describe('Teacher controllers', () => { | describe('Teacher controllers', () => { | ||||||
|  |  | ||||||
|  | @ -19,8 +19,7 @@ import { TeacherDTO } from '@dwengo-1/common/interfaces/teacher'; | ||||||
| import { getClassHandler } from '../../src/controllers/classes'; | import { getClassHandler } from '../../src/controllers/classes'; | ||||||
| import { getFooFighters, getTestleerkracht1 } from '../test_assets/users/teachers.testdata.js'; | import { getFooFighters, getTestleerkracht1 } from '../test_assets/users/teachers.testdata.js'; | ||||||
| import { getClass02 } from '../test_assets/classes/classes.testdata.js'; | import { getClass02 } from '../test_assets/classes/classes.testdata.js'; | ||||||
| import { getPinkFloyd, TEST_STUDENTS } from '../test_assets/users/students.testdata.js'; | import { getClassJoinRequest01 } from '../test_assets/classes/class-join-requests.testdata.js'; | ||||||
| import { getClassJoinRequest01, getClassJoinRequest02 } from '../test_assets/classes/class-join-requests.testdata.js'; |  | ||||||
| 
 | 
 | ||||||
| describe('Teacher controllers', () => { | describe('Teacher controllers', () => { | ||||||
|     let req: Partial<Request>; |     let req: Partial<Request>; | ||||||
|  |  | ||||||
|  | @ -2,7 +2,7 @@ import { beforeAll, describe, expect, it } from 'vitest'; | ||||||
| import { setupTestApp } from '../../setup-tests'; | import { setupTestApp } from '../../setup-tests'; | ||||||
| import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository'; | import { AssignmentRepository } from '../../../src/data/assignments/assignment-repository'; | ||||||
| import { getAssignmentRepository } from '../../../src/data/repositories'; | import { getAssignmentRepository } from '../../../src/data/repositories'; | ||||||
| import { getClass01, getClass02 } from '../../test_assets/classes/classes.testdata'; | import { getClass02 } from '../../test_assets/classes/classes.testdata'; | ||||||
| import { getAssignment02, getAssignment03 } from '../../test_assets/assignments/assignments.testdata'; | import { getAssignment02, getAssignment03 } from '../../test_assets/assignments/assignments.testdata'; | ||||||
| import { getTestleerkracht1 } from '../../test_assets/users/teachers.testdata'; | import { getTestleerkracht1 } from '../../test_assets/users/teachers.testdata'; | ||||||
| 
 | 
 | ||||||
|  | @ -17,7 +17,7 @@ describe('AssignmentRepository', () => { | ||||||
|     it('should return the requested assignment', async () => { |     it('should return the requested assignment', async () => { | ||||||
|         const class_ = getClass02(); |         const class_ = getClass02(); | ||||||
|         const usedAssignment = getAssignment02(); |         const usedAssignment = getAssignment02(); | ||||||
|         const assignment = await assignmentRepository.findByClassAndId(class_!, 21001); |         const assignment = await assignmentRepository.findByClassAndId(class_, 21001); | ||||||
| 
 | 
 | ||||||
|         expect(assignment).toBeTruthy(); |         expect(assignment).toBeTruthy(); | ||||||
|         expect(assignment!.description).toBe(usedAssignment.description); |         expect(assignment!.description).toBe(usedAssignment.description); | ||||||
|  | @ -30,7 +30,7 @@ describe('AssignmentRepository', () => { | ||||||
|     it('should return all assignments for a class', async () => { |     it('should return all assignments for a class', async () => { | ||||||
|         const class_ = getClass02(); |         const class_ = getClass02(); | ||||||
|         const usedAssignment = getAssignment02(); |         const usedAssignment = getAssignment02(); | ||||||
|         const assignments = await assignmentRepository.findAllAssignmentsInClass(class_!); |         const assignments = await assignmentRepository.findAllAssignmentsInClass(class_); | ||||||
| 
 | 
 | ||||||
|         expect(assignments).toBeTruthy(); |         expect(assignments).toBeTruthy(); | ||||||
|         expect(assignments).toHaveLength(1); |         expect(assignments).toHaveLength(1); | ||||||
|  |  | ||||||
|  | @ -1,8 +1,7 @@ | ||||||
| import { beforeAll, describe, expect, it } from 'vitest'; | import { beforeAll, describe, expect, it } from 'vitest'; | ||||||
| import { setupTestApp } from '../../setup-tests'; | import { setupTestApp } from '../../setup-tests'; | ||||||
| import { GroupRepository } from '../../../src/data/assignments/group-repository'; | import { GroupRepository } from '../../../src/data/assignments/group-repository'; | ||||||
| import { getAssignmentRepository, getClassRepository, getGroupRepository } from '../../../src/data/repositories'; | import { getGroupRepository } from '../../../src/data/repositories'; | ||||||
| import { getClass01 } from '../../test_assets/classes/classes.testdata'; |  | ||||||
| import { getAssignment01, getAssignment02 } from '../../test_assets/assignments/assignments.testdata'; | import { getAssignment01, getAssignment02 } from '../../test_assets/assignments/assignments.testdata'; | ||||||
| import { getTestGroup01, getTestGroup02, getTestGroup03 } from '../../test_assets/assignments/groups.testdata'; | import { getTestGroup01, getTestGroup02, getTestGroup03 } from '../../test_assets/assignments/groups.testdata'; | ||||||
| import { getDireStraits, getNoordkaap } from '../../test_assets/users/students.testdata'; | import { getDireStraits, getNoordkaap } from '../../test_assets/users/students.testdata'; | ||||||
|  | @ -21,7 +20,7 @@ describe('GroupRepository', () => { | ||||||
|         const member1 = getNoordkaap(); |         const member1 = getNoordkaap(); | ||||||
|         const member2 = getDireStraits(); |         const member2 = getDireStraits(); | ||||||
| 
 | 
 | ||||||
|         const group = await groupRepository.findByAssignmentAndGroupNumber(assignment!, usedGroup.groupNumber!); |         const group = await groupRepository.findByAssignmentAndGroupNumber(assignment, usedGroup.groupNumber!); | ||||||
| 
 | 
 | ||||||
|         expect(group).toBeTruthy(); |         expect(group).toBeTruthy(); | ||||||
|         expect(group?.groupNumber).toBe(usedGroup.groupNumber); |         expect(group?.groupNumber).toBe(usedGroup.groupNumber); | ||||||
|  | @ -36,7 +35,7 @@ describe('GroupRepository', () => { | ||||||
|         const gr2 = getTestGroup02(); |         const gr2 = getTestGroup02(); | ||||||
|         const gr3 = getTestGroup03(); |         const gr3 = getTestGroup03(); | ||||||
| 
 | 
 | ||||||
|         const groups = await groupRepository.findAllGroupsForAssignment(assignment!); |         const groups = await groupRepository.findAllGroupsForAssignment(assignment); | ||||||
| 
 | 
 | ||||||
|         expect(groups).toBeTruthy(); |         expect(groups).toBeTruthy(); | ||||||
|         expect(groups).toHaveLength(3); |         expect(groups).toHaveLength(3); | ||||||
|  | @ -49,9 +48,9 @@ describe('GroupRepository', () => { | ||||||
|         const assignment = getAssignment02(); |         const assignment = getAssignment02(); | ||||||
|         const deleted = getTestGroup01(); |         const deleted = getTestGroup01(); | ||||||
| 
 | 
 | ||||||
|         await groupRepository.deleteByAssignmentAndGroupNumber(assignment!, deleted.groupNumber!); |         await groupRepository.deleteByAssignmentAndGroupNumber(assignment, deleted.groupNumber!); | ||||||
| 
 | 
 | ||||||
|         const group = await groupRepository.findByAssignmentAndGroupNumber(assignment!, deleted.groupNumber!); |         const group = await groupRepository.findByAssignmentAndGroupNumber(assignment, deleted.groupNumber!); | ||||||
| 
 | 
 | ||||||
|         expect(group).toBeNull(); |         expect(group).toBeNull(); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -2,20 +2,12 @@ import { beforeAll, describe, expect, it } from 'vitest'; | ||||||
| import { setupTestApp } from '../../setup-tests'; | import { setupTestApp } from '../../setup-tests'; | ||||||
| import { SubmissionRepository } from '../../../src/data/assignments/submission-repository'; | import { SubmissionRepository } from '../../../src/data/assignments/submission-repository'; | ||||||
| import { | import { | ||||||
|     getAssignmentRepository, |  | ||||||
|     getClassRepository, |  | ||||||
|     getGroupRepository, |  | ||||||
|     getStudentRepository, |  | ||||||
|     getSubmissionRepository, |     getSubmissionRepository, | ||||||
| } from '../../../src/data/repositories'; | } from '../../../src/data/repositories'; | ||||||
| import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; | import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; | ||||||
| import { Language } from '@dwengo-1/common/util/language'; |  | ||||||
| import { Submission } from '../../../src/entities/assignments/submission.entity'; | import { Submission } from '../../../src/entities/assignments/submission.entity'; | ||||||
| import { Class } from '../../../src/entities/classes/class.entity'; | import { testLearningObject01 } from '../../test_assets/content/learning-objects.testdata'; | ||||||
| import { Assignment } from '../../../src/entities/assignments/assignment.entity'; |  | ||||||
| import { testLearningObject01, testLearningObject03 } from '../../test_assets/content/learning-objects.testdata'; |  | ||||||
| import { getSubmission01, getSubmission02, getSubmission07, getSubmission08 } from '../../test_assets/assignments/submission.testdata'; | import { getSubmission01, getSubmission02, getSubmission07, getSubmission08 } from '../../test_assets/assignments/submission.testdata'; | ||||||
| import { use } from 'marked'; |  | ||||||
| import { getAssignment01 } from '../../test_assets/assignments/assignments.testdata'; | import { getAssignment01 } from '../../test_assets/assignments/assignments.testdata'; | ||||||
| import { getTestGroup02 } from '../../test_assets/assignments/groups.testdata'; | import { getTestGroup02 } from '../../test_assets/assignments/groups.testdata'; | ||||||
| 
 | 
 | ||||||
|  | @ -42,7 +34,7 @@ describe('SubmissionRepository', () => { | ||||||
|         const usedSubmission = getSubmission02(); |         const usedSubmission = getSubmission02(); | ||||||
|         const id = new LearningObjectIdentifier(usedSubmission.learningObjectHruid, usedSubmission.learningObjectLanguage, usedSubmission.learningObjectVersion); |         const id = new LearningObjectIdentifier(usedSubmission.learningObjectHruid, usedSubmission.learningObjectLanguage, usedSubmission.learningObjectVersion); | ||||||
|          |          | ||||||
|         const submission = await submissionRepository.findMostRecentSubmissionForStudent(id, usedSubmission.submitter!); |         const submission = await submissionRepository.findMostRecentSubmissionForStudent(id, usedSubmission.submitter); | ||||||
| 
 | 
 | ||||||
|         expect(submission).toBeTruthy(); |         expect(submission).toBeTruthy(); | ||||||
|         expect(submission?.submissionTime).toStrictEqual(usedSubmission.submissionTime); |         expect(submission?.submissionTime).toStrictEqual(usedSubmission.submissionTime); | ||||||
|  | @ -67,7 +59,7 @@ describe('SubmissionRepository', () => { | ||||||
|             language: usedSubmission.learningObjectLanguage, |             language: usedSubmission.learningObjectLanguage, | ||||||
|             version: usedSubmission.learningObjectVersion, |             version: usedSubmission.learningObjectVersion, | ||||||
|         }; |         }; | ||||||
|         const result = await submissionRepository.findAllSubmissionsForLearningObjectAndAssignment(loId, assignment!); |         const result = await submissionRepository.findAllSubmissionsForLearningObjectAndAssignment(loId, assignment); | ||||||
|         sortSubmissions(result); |         sortSubmissions(result); | ||||||
| 
 | 
 | ||||||
|         expect(result).toHaveLength(3); |         expect(result).toHaveLength(3); | ||||||
|  | @ -94,7 +86,7 @@ describe('SubmissionRepository', () => { | ||||||
|             version: usedSubmission.learningObjectVersion, |             version: usedSubmission.learningObjectVersion, | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         const result = await submissionRepository.findAllSubmissionsForLearningObjectAndGroup(loId, group!); |         const result = await submissionRepository.findAllSubmissionsForLearningObjectAndGroup(loId, group); | ||||||
| 
 | 
 | ||||||
|         expect(result).toHaveLength(1); |         expect(result).toHaveLength(1); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -1,7 +1,7 @@ | ||||||
| import { beforeAll, describe, expect, it } from 'vitest'; | import { beforeAll, describe, expect, it } from 'vitest'; | ||||||
| import { setupTestApp } from '../../setup-tests'; | import { setupTestApp } from '../../setup-tests'; | ||||||
| import { ClassJoinRequestRepository } from '../../../src/data/classes/class-join-request-repository'; | import { ClassJoinRequestRepository } from '../../../src/data/classes/class-join-request-repository'; | ||||||
| import { getClassJoinRequestRepository, getClassRepository, getStudentRepository } from '../../../src/data/repositories'; | import { getClassJoinRequestRepository } from '../../../src/data/repositories'; | ||||||
| import { getPinkFloyd, getSmashingPumpkins } from '../../test_assets/users/students.testdata'; | import { getPinkFloyd, getSmashingPumpkins } from '../../test_assets/users/students.testdata'; | ||||||
| import { getClass02, getClass03 } from '../../test_assets/classes/classes.testdata'; | import { getClass02, getClass03 } from '../../test_assets/classes/classes.testdata'; | ||||||
| import { getClassJoinRequest01, getClassJoinRequest02, getClassJoinRequest03 } from '../../test_assets/classes/class-join-requests.testdata'; | import { getClassJoinRequest01, getClassJoinRequest02, getClassJoinRequest03 } from '../../test_assets/classes/class-join-requests.testdata'; | ||||||
|  | @ -30,7 +30,7 @@ describe('ClassJoinRequestRepository', () => { | ||||||
|         const class_ = getClass02(); |         const class_ = getClass02(); | ||||||
|         const jr1 = getClassJoinRequest01(); |         const jr1 = getClassJoinRequest01(); | ||||||
|         const jr2 = getClassJoinRequest02(); |         const jr2 = getClassJoinRequest02(); | ||||||
|         const requests = await classJoinRequestRepository.findAllOpenRequestsTo(class_!); |         const requests = await classJoinRequestRepository.findAllOpenRequestsTo(class_); | ||||||
| 
 | 
 | ||||||
|         expect(requests).toBeTruthy(); |         expect(requests).toBeTruthy(); | ||||||
|         expect(requests).toHaveLength(2); |         expect(requests).toHaveLength(2); | ||||||
|  | @ -41,9 +41,9 @@ describe('ClassJoinRequestRepository', () => { | ||||||
|     it('should not find a removed request', async () => { |     it('should not find a removed request', async () => { | ||||||
|         const studentUsed = getSmashingPumpkins(); |         const studentUsed = getSmashingPumpkins(); | ||||||
|         const class_ = getClass03(); |         const class_ = getClass03(); | ||||||
|         await classJoinRequestRepository.deleteBy(studentUsed!, class_!); |         await classJoinRequestRepository.deleteBy(studentUsed, class_); | ||||||
| 
 | 
 | ||||||
|         const request = await classJoinRequestRepository.findAllRequestsBy(studentUsed!); |         const request = await classJoinRequestRepository.findAllRequestsBy(studentUsed); | ||||||
| 
 | 
 | ||||||
|         expect(request).toHaveLength(0); |         expect(request).toHaveLength(0); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -1,6 +1,6 @@ | ||||||
| import { beforeAll, describe, expect, it } from 'vitest'; | import { beforeAll, describe, expect, it } from 'vitest'; | ||||||
| import { setupTestApp } from '../../setup-tests'; | import { setupTestApp } from '../../setup-tests'; | ||||||
| import { getTeacherInvitationRepository, getTeacherRepository } from '../../../src/data/repositories'; | import { getTeacherInvitationRepository } from '../../../src/data/repositories'; | ||||||
| import { TeacherInvitationRepository } from '../../../src/data/classes/teacher-invitation-repository'; | import { TeacherInvitationRepository } from '../../../src/data/classes/teacher-invitation-repository'; | ||||||
| import { getFooFighters, getLimpBizkit } from '../../test_assets/users/teachers.testdata'; | import { getFooFighters, getLimpBizkit } from '../../test_assets/users/teachers.testdata'; | ||||||
| import { getTeacherInvitation01, getTeacherInvitation02, getTeacherInvitation03 } from '../../test_assets/classes/teacher-invitations.testdata'; | import { getTeacherInvitation01, getTeacherInvitation02, getTeacherInvitation03 } from '../../test_assets/classes/teacher-invitations.testdata'; | ||||||
|  | @ -18,7 +18,7 @@ describe('ClassRepository', () => { | ||||||
|         const teacher = getLimpBizkit(); |         const teacher = getLimpBizkit(); | ||||||
|         const ti1 = getTeacherInvitation01(); |         const ti1 = getTeacherInvitation01(); | ||||||
|         const ti2 = getTeacherInvitation02(); |         const ti2 = getTeacherInvitation02(); | ||||||
|         const invitations = await teacherInvitationRepository.findAllInvitationsBy(teacher!); |         const invitations = await teacherInvitationRepository.findAllInvitationsBy(teacher); | ||||||
| 
 | 
 | ||||||
|         expect(invitations).toBeTruthy(); |         expect(invitations).toBeTruthy(); | ||||||
|         expect(invitations).toHaveLength(2); |         expect(invitations).toHaveLength(2); | ||||||
|  | @ -30,7 +30,7 @@ describe('ClassRepository', () => { | ||||||
|         const teacher = getFooFighters(); |         const teacher = getFooFighters(); | ||||||
|         const ti1 = getTeacherInvitation01(); |         const ti1 = getTeacherInvitation01(); | ||||||
|         const ti2 = getTeacherInvitation03(); |         const ti2 = getTeacherInvitation03(); | ||||||
|         const invitations = await teacherInvitationRepository.findAllInvitationsFor(teacher!); |         const invitations = await teacherInvitationRepository.findAllInvitationsFor(teacher); | ||||||
| 
 | 
 | ||||||
|         expect(invitations).toBeTruthy(); |         expect(invitations).toBeTruthy(); | ||||||
|         expect(invitations).toHaveLength(2); |         expect(invitations).toHaveLength(2); | ||||||
|  | @ -42,7 +42,7 @@ describe('ClassRepository', () => { | ||||||
|         const class_ = getClass02(); |         const class_ = getClass02(); | ||||||
|         const ti1 = getTeacherInvitation01(); |         const ti1 = getTeacherInvitation01(); | ||||||
|         const ti2 = getTeacherInvitation02(); |         const ti2 = getTeacherInvitation02(); | ||||||
|         const invitations = await teacherInvitationRepository.findAllInvitationsForClass(class_!); |         const invitations = await teacherInvitationRepository.findAllInvitationsForClass(class_); | ||||||
| 
 | 
 | ||||||
|         expect(invitations).toBeTruthy(); |         expect(invitations).toBeTruthy(); | ||||||
|         expect(invitations).toHaveLength(2); |         expect(invitations).toHaveLength(2); | ||||||
|  | @ -55,9 +55,9 @@ describe('ClassRepository', () => { | ||||||
|         const class_ = getClass01(); |         const class_ = getClass01(); | ||||||
|         const sender = getFooFighters(); |         const sender = getFooFighters(); | ||||||
|         const receiver = getLimpBizkit(); |         const receiver = getLimpBizkit(); | ||||||
|         await teacherInvitationRepository.deleteBy(class_!, sender!, receiver!); |         await teacherInvitationRepository.deleteBy(class_, sender, receiver); | ||||||
| 
 | 
 | ||||||
|         const invitation = await teacherInvitationRepository.findAllInvitationsBy(sender!); |         const invitation = await teacherInvitationRepository.findAllInvitationsBy(sender); | ||||||
| 
 | 
 | ||||||
|         expect(invitation).toHaveLength(0); |         expect(invitation).toHaveLength(0); | ||||||
|     }); |     }); | ||||||
|  |  | ||||||
|  | @ -2,7 +2,6 @@ import { beforeAll, describe, expect, it } from 'vitest'; | ||||||
| import { setupTestApp } from '../../setup-tests.js'; | import { setupTestApp } from '../../setup-tests.js'; | ||||||
| import { getAttachmentRepository } from '../../../src/data/repositories.js'; | import { getAttachmentRepository } from '../../../src/data/repositories.js'; | ||||||
| import { AttachmentRepository } from '../../../src/data/content/attachment-repository.js'; | import { AttachmentRepository } from '../../../src/data/content/attachment-repository.js'; | ||||||
| import { testLearningObject02 } from '../../test_assets/content/learning-objects.testdata'; |  | ||||||
| import { getAttachment01 } from '../../test_assets/content/attachments.testdata.js'; | import { getAttachment01 } from '../../test_assets/content/attachments.testdata.js'; | ||||||
| 
 | 
 | ||||||
| describe('AttachmentRepository', () => { | describe('AttachmentRepository', () => { | ||||||
|  |  | ||||||
|  | @ -6,7 +6,6 @@ import { LearningObject } from '../../../src/entities/content/learning-object.en | ||||||
| import { expectToBeCorrectEntity } from '../../test-utils/expectations.js'; | import { expectToBeCorrectEntity } from '../../test-utils/expectations.js'; | ||||||
| import { testLearningObject01, testLearningObject02, testLearningObject03 } from '../../test_assets/content/learning-objects.testdata'; | import { testLearningObject01, testLearningObject02, testLearningObject03 } from '../../test_assets/content/learning-objects.testdata'; | ||||||
| import { v4 } from 'uuid'; | import { v4 } from 'uuid'; | ||||||
| import { wrap } from '@mikro-orm/core'; |  | ||||||
| 
 | 
 | ||||||
| describe('LearningObjectRepository', () => { | describe('LearningObjectRepository', () => { | ||||||
|     let learningObjectRepository: LearningObjectRepository; |     let learningObjectRepository: LearningObjectRepository; | ||||||
|  | @ -38,7 +37,7 @@ describe('LearningObjectRepository', () => { | ||||||
|     let newerExample: LearningObject; |     let newerExample: LearningObject; | ||||||
| 
 | 
 | ||||||
|     it('should allow a learning object with the same id except a different version to be added', async () => { |     it('should allow a learning object with the same id except a different version to be added', async () => { | ||||||
|         // structeredClone failed on teacher, this copies all fields to a json object
 |         // StructeredClone failed on teacher, this copies all fields to a json object
 | ||||||
|         const testLearningObject01Newer = { ...testLearningObject01 }; |         const testLearningObject01Newer = { ...testLearningObject01 }; | ||||||
|         testLearningObject01Newer.version = 10; |         testLearningObject01Newer.version = 10; | ||||||
|         testLearningObject01Newer.title += ' (nieuw)'; |         testLearningObject01Newer.title += ' (nieuw)'; | ||||||
|  | @ -48,15 +47,6 @@ describe('LearningObjectRepository', () => { | ||||||
|         await learningObjectRepository.save(newerExample); |         await learningObjectRepository.save(newerExample); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it('should return the newest version of the learning object when queried by only hruid and language', async () => { |  | ||||||
|          |  | ||||||
| 
 |  | ||||||
|         const result = await learningObjectRepository.findLatestByHruidAndLanguage(newerExample.hruid, newerExample.language); |  | ||||||
|         // expect(result).toBeInstanceOf(LearningObject);
 |  | ||||||
|         // expect(result?.version).toBe(10);
 |  | ||||||
|         // expect(result?.title).toContain('(nieuw)');
 |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
|     it('should return null when queried by non-existing hruid or language', async () => { |     it('should return null when queried by non-existing hruid or language', async () => { | ||||||
|         const result = await learningObjectRepository.findLatestByHruidAndLanguage('something_that_does_not_exist', testLearningObject01.language); |         const result = await learningObjectRepository.findLatestByHruidAndLanguage('something_that_does_not_exist', testLearningObject01.language); | ||||||
|         expect(result).toBe(null); |         expect(result).toBe(null); | ||||||
|  |  | ||||||
|  | @ -1,15 +1,10 @@ | ||||||
| import { beforeAll, describe, expect, it } from 'vitest'; | import { beforeAll, describe, expect, it } from 'vitest'; | ||||||
| import { setupTestApp } from '../../setup-tests'; | import { setupTestApp } from '../../setup-tests'; | ||||||
| import { AnswerRepository } from '../../../src/data/questions/answer-repository'; | import { AnswerRepository } from '../../../src/data/questions/answer-repository'; | ||||||
| import { getAnswerRepository, getQuestionRepository, getTeacherRepository } from '../../../src/data/repositories'; | import { getAnswerRepository } from '../../../src/data/repositories'; | ||||||
| import { QuestionRepository } from '../../../src/data/questions/question-repository'; | import { getQuestion01, getQuestion02 } from '../../test_assets/questions/questions.testdata'; | ||||||
| import { LearningObjectIdentifier } from '../../../src/entities/content/learning-object-identifier'; |  | ||||||
| import { Language } from '@dwengo-1/common/util/language'; |  | ||||||
| import { TeacherRepository } from '../../../src/data/users/teacher-repository'; |  | ||||||
| import { getQuestion01, getQuestion02, getQuestion04, getQuestion05, getQuestion06 } from '../../test_assets/questions/questions.testdata'; |  | ||||||
| import { getAnswer01, getAnswer02, getAnswer03 } from '../../test_assets/questions/answers.testdata'; | import { getAnswer01, getAnswer02, getAnswer03 } from '../../test_assets/questions/answers.testdata'; | ||||||
| import { getFooFighters } from '../../test_assets/users/teachers.testdata'; | import { getFooFighters } from '../../test_assets/users/teachers.testdata'; | ||||||
| import { testLearningObject05 } from '../../test_assets/content/learning-objects.testdata'; |  | ||||||
| 
 | 
 | ||||||
| describe('AnswerRepository', () => { | describe('AnswerRepository', () => { | ||||||
|     let answerRepository: AnswerRepository; |     let answerRepository: AnswerRepository; | ||||||
|  | @ -24,7 +19,7 @@ describe('AnswerRepository', () => { | ||||||
|         const a1 = getAnswer01(); |         const a1 = getAnswer01(); | ||||||
|         const a2 = getAnswer02(); |         const a2 = getAnswer02(); | ||||||
| 
 | 
 | ||||||
|         const answers = await answerRepository.findAllAnswersToQuestion(question!); |         const answers = await answerRepository.findAllAnswersToQuestion(question); | ||||||
| 
 | 
 | ||||||
|         expect(answers).toBeTruthy(); |         expect(answers).toBeTruthy(); | ||||||
|         expect(answers).toHaveLength(2); |         expect(answers).toHaveLength(2); | ||||||
|  | @ -38,7 +33,7 @@ describe('AnswerRepository', () => { | ||||||
| 
 | 
 | ||||||
|         await answerRepository.createAnswer({ |         await answerRepository.createAnswer({ | ||||||
|             toQuestion: question, |             toQuestion: question, | ||||||
|             author: teacher!, |             author: teacher, | ||||||
|             content: 'created answer', |             content: 'created answer', | ||||||
|         }); |         }); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -48,8 +48,8 @@ describe('QuestionRepository', () => { | ||||||
|         const group = getTestGroup01(); |         const group = getTestGroup01(); | ||||||
|         await questionRepository.createQuestion({ |         await questionRepository.createQuestion({ | ||||||
|             loId: id, |             loId: id, | ||||||
|             inGroup: group!, |             inGroup: group, | ||||||
|             author: student!, |             author: student, | ||||||
|             content: 'question?', |             content: 'question?', | ||||||
|         }); |         }); | ||||||
|         const question = await questionRepository.findAllQuestionsAboutLearningObject(id); |         const question = await questionRepository.findAllQuestionsAboutLearningObject(id); | ||||||
|  | @ -66,7 +66,7 @@ describe('QuestionRepository', () => { | ||||||
|             language: testLearningObject05.language, |             language: testLearningObject05.language, | ||||||
|             version: testLearningObject05.version, |             version: testLearningObject05.version, | ||||||
|         }; |         }; | ||||||
|         const result = await questionRepository.findAllQuestionsAboutLearningObjectInAssignment(loId, assignment!); |         const result = await questionRepository.findAllQuestionsAboutLearningObjectInAssignment(loId, assignment); | ||||||
|         sortQuestions(result); |         sortQuestions(result); | ||||||
| 
 | 
 | ||||||
|         expect(result).toHaveLength(3); |         expect(result).toHaveLength(3); | ||||||
|  | @ -94,7 +94,7 @@ describe('QuestionRepository', () => { | ||||||
|         }; |         }; | ||||||
|         const assignment = getAssignment01(); |         const assignment = getAssignment01(); | ||||||
| 
 | 
 | ||||||
|         const result = await questionRepository.findAllQuestionsAboutLearningObjectInAssignment(loId, assignment!, getTool().username); |         const result = await questionRepository.findAllQuestionsAboutLearningObjectInAssignment(loId, assignment, getTool().username); | ||||||
|         // (student Tool is in group #2)
 |         // (student Tool is in group #2)
 | ||||||
| 
 | 
 | ||||||
|         expect(result).toHaveLength(1); |         expect(result).toHaveLength(1); | ||||||
|  |  | ||||||
|  | @ -2,7 +2,6 @@ import { setupTestApp } from '../../setup-tests.js'; | ||||||
| import { describe, it, expect, beforeAll } from 'vitest'; | import { describe, it, expect, beforeAll } from 'vitest'; | ||||||
| import { StudentRepository } from '../../../src/data/users/student-repository.js'; | import { StudentRepository } from '../../../src/data/users/student-repository.js'; | ||||||
| import { getStudentRepository } from '../../../src/data/repositories.js'; | import { getStudentRepository } from '../../../src/data/repositories.js'; | ||||||
| import { getNameOfJSDocTypedef } from 'typescript'; |  | ||||||
| import { getNoordkaap } from '../../test_assets/users/students.testdata.js'; | import { getNoordkaap } from '../../test_assets/users/students.testdata.js'; | ||||||
| 
 | 
 | ||||||
| const username = 'teststudent'; | const username = 'teststudent'; | ||||||
|  |  | ||||||
|  | @ -8,7 +8,7 @@ export function makeTestGroups(em: EntityManager): Group[] { | ||||||
|      * Group #1 for Assignment #1 in class 'id01' |      * Group #1 for Assignment #1 in class 'id01' | ||||||
|      * => Assigned to do learning path 'id02' |      * => Assigned to do learning path 'id02' | ||||||
|      */ |      */ | ||||||
|     // gets deleted
 |     // Gets deleted
 | ||||||
|     group01 = em.create(Group, { |     group01 = em.create(Group, { | ||||||
|         assignment: getAssignment01(), |         assignment: getAssignment01(), | ||||||
|         groupNumber: 21001, |         groupNumber: 21001, | ||||||
|  |  | ||||||
|  | @ -71,7 +71,7 @@ export function makeTestSubmissions(em: EntityManager): Submission[] { | ||||||
|         content: '', |         content: '', | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     // gets deleted
 |     // Gets deleted
 | ||||||
|     submission07 = em.create(Submission, { |     submission07 = em.create(Submission, { | ||||||
|         learningObjectHruid: testLearningObject01.hruid, |         learningObjectHruid: testLearningObject01.hruid, | ||||||
|         learningObjectLanguage: testLearningObject01.language, |         learningObjectLanguage: testLearningObject01.language, | ||||||
|  |  | ||||||
|  | @ -39,7 +39,7 @@ export function makeTestClasses(em: EntityManager): Class[] { | ||||||
|     const studentsClass04: Student[] = [getNoordkaap(), getDireStraits()]; |     const studentsClass04: Student[] = [getNoordkaap(), getDireStraits()]; | ||||||
|     const teacherClass04: Teacher[] = [getStaind()]; |     const teacherClass04: Teacher[] = [getStaind()]; | ||||||
| 
 | 
 | ||||||
|     // gets deleted in test
 |     // Gets deleted in test
 | ||||||
|     class04 = em.create(Class, { |     class04 = em.create(Class, { | ||||||
|         classId: 'Q8N5YC', // 33d03536-83b8-4880-9982-9bbf2f908ddf
 |         classId: 'Q8N5YC', // 33d03536-83b8-4880-9982-9bbf2f908ddf
 | ||||||
|         displayName: 'class04', |         displayName: 'class04', | ||||||
|  |  | ||||||
|  | @ -26,7 +26,7 @@ export function makeTestTeacherInvitations(em: EntityManager): TeacherInvitation | ||||||
|         status: ClassStatus.Open, |         status: ClassStatus.Open, | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     // gets deleted in test
 |     // Gets deleted in test
 | ||||||
|     teacherInvitation04 = em.create(TeacherInvitation, { |     teacherInvitation04 = em.create(TeacherInvitation, { | ||||||
|         sender: getFooFighters(), |         sender: getFooFighters(), | ||||||
|         receiver: getLimpBizkit(), |         receiver: getLimpBizkit(), | ||||||
|  |  | ||||||
|  | @ -4,7 +4,7 @@ import { testLearningObject01 } from './learning-objects.testdata'; | ||||||
| import { LearningObject } from '../../../src/entities/content/learning-object.entity'; | import { LearningObject } from '../../../src/entities/content/learning-object.entity'; | ||||||
| 
 | 
 | ||||||
| export function makeTestAttachments(em: EntityManager): Attachment[] { | export function makeTestAttachments(em: EntityManager): Attachment[] { | ||||||
|     // prevent duplicate insertion
 |     // Prevent duplicate insertion
 | ||||||
|     const lo = em.merge(LearningObject, testLearningObject01); |     const lo = em.merge(LearningObject, testLearningObject01); | ||||||
| 
 | 
 | ||||||
|     attachment01 = em.create(Attachment, { |     attachment01 = em.create(Attachment, { | ||||||
|  |  | ||||||
|  | @ -20,7 +20,7 @@ export function makeTestAnswers(em: EntityManager): Answer[] { | ||||||
|         content: 'answer2', |         content: 'answer2', | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     // gets deleted
 |     // Gets deleted
 | ||||||
|     answer03 = em.create(Answer, { |     answer03 = em.create(Answer, { | ||||||
|         author: getLimpBizkit(), |         author: getLimpBizkit(), | ||||||
|         toQuestion: getQuestion04(), |         toQuestion: getQuestion04(), | ||||||
|  |  | ||||||
|  | @ -27,7 +27,7 @@ export function makeTestQuestions(em: EntityManager): Question[] { | ||||||
|         content: 'question', |         content: 'question', | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     //gets deleted
 |     //Gets deleted
 | ||||||
|     question03 = em.create(Question, { |     question03 = em.create(Question, { | ||||||
|         learningObjectLanguage: testLearningObject04.language, |         learningObjectLanguage: testLearningObject04.language, | ||||||
|         learningObjectVersion: testLearningObject04.version, |         learningObjectVersion: testLearningObject04.version, | ||||||
|  |  | ||||||
		Reference in a new issue
	
	 laurejablonski
						laurejablonski