fix(backend): Falende testen gerepareerd.
This commit is contained in:
		
							parent
							
								
									fc675710b4
								
							
						
					
					
						commit
						ba725f67b2
					
				
					 4 changed files with 13 additions and 24 deletions
				
			
		|  | @ -22,7 +22,10 @@ interface QuestionQueryParams { | |||
|     lang: string; | ||||
| } | ||||
| 
 | ||||
| function getObjectId(req: Request<QuestionPathParams, any, any, QuestionQueryParams>, res: Response): LearningObjectIdentifier | null { | ||||
| function getObjectId<ResBody, ReqBody>( | ||||
|     req: Request<QuestionPathParams, ResBody, ReqBody, QuestionQueryParams>, | ||||
|     res: Response | ||||
| ): LearningObjectIdentifier | null { | ||||
|     const { hruid, version } = req.params; | ||||
|     const lang = req.query.lang; | ||||
| 
 | ||||
|  | @ -41,7 +44,10 @@ function getObjectId(req: Request<QuestionPathParams, any, any, QuestionQueryPar | |||
| interface GetQuestionIdPathParams extends QuestionPathParams { | ||||
|     seq: string; | ||||
| } | ||||
| function getQuestionId(req: Request<GetQuestionIdPathParams, any, any, QuestionQueryParams>, res: Response): QuestionId | null { | ||||
| function getQuestionId<ReqBody, ResBody>( | ||||
|     req: Request<GetQuestionIdPathParams, ReqBody, ResBody, QuestionQueryParams>, | ||||
|     res: Response | ||||
| ): QuestionId | null { | ||||
|     const seq = req.params.seq; | ||||
|     const learningObjectIdentifier = getObjectId(req, res); | ||||
| 
 | ||||
|  |  | |||
|  | @ -33,7 +33,9 @@ describe('AssignmentRepository', () => { | |||
| 
 | ||||
|     it('should find all by username of the responsible teacher', async () => { | ||||
|         const result = await assignmentRepository.findAllByResponsibleTeacher("FooFighters") | ||||
|         const resultIds = result.map(it => it.id).sort(); | ||||
|         const resultIds = result | ||||
|                                                 .map(it => it.id) | ||||
|                                                 .sort((a, b) => (a ?? 0) - (b ?? 0)); | ||||
| 
 | ||||
|         expect(resultIds).toEqual([1, 3, 4]); | ||||
|     }); | ||||
|  |  | |||
|  | @ -18,25 +18,6 @@ import {Submission} from "../../../src/entities/assignments/submission.entity"; | |||
| import {Class} from "../../../src/entities/classes/class.entity"; | ||||
| import {Assignment} from "../../../src/entities/assignments/assignment.entity"; | ||||
| 
 | ||||
| export function checkSubmissionsForStudentNoordkaap(result: Submission[]) { | ||||
|     sortSubmissions(result); | ||||
| 
 | ||||
|     expect(result[0].learningObjectHruid).toBe("id01"); | ||||
|     expect(result[0].submissionNumber).toBe(2); | ||||
| 
 | ||||
|     expect(result[1].learningObjectHruid).toBe("id02"); | ||||
|     expect(result[1].submissionNumber).toBe(1); | ||||
| 
 | ||||
|     expect(result[2].learningObjectHruid).toBe("id02"); | ||||
|     expect(result[2].submissionNumber).toBe(2); | ||||
| 
 | ||||
|     expect(result[3].learningObjectHruid).toBe("id03"); | ||||
|     expect(result[3].submissionNumber).toBe(1); | ||||
| 
 | ||||
|     expect(result[4].learningObjectHruid).toBe("id03"); | ||||
|     expect(result[4].submissionNumber).toBe(2); | ||||
| } | ||||
| 
 | ||||
| describe('SubmissionRepository', () => { | ||||
|     let submissionRepository: SubmissionRepository; | ||||
|     let studentRepository: StudentRepository; | ||||
|  | @ -135,7 +116,7 @@ describe('SubmissionRepository', () => { | |||
|     }); | ||||
| }); | ||||
| 
 | ||||
| function sortSubmissions(submissions: Submission[]) { | ||||
| function sortSubmissions(submissions: Submission[]): void { | ||||
|     submissions.sort((a, b) => { | ||||
|         if (a.learningObjectHruid < b.learningObjectHruid) {return -1;} | ||||
|         if (a.learningObjectHruid > b.learningObjectHruid) {return 1;} | ||||
|  |  | |||
|  | @ -108,7 +108,7 @@ describe('QuestionRepository', () => { | |||
|     }); | ||||
| }); | ||||
| 
 | ||||
| function sortQuestions(questions: Question[]) { | ||||
| function sortQuestions(questions: Question[]): void { | ||||
|     questions.sort((a, b) => { | ||||
|         if (a.learningObjectHruid < b.learningObjectHruid) {return -1} | ||||
|         else if (a.learningObjectHruid > b.learningObjectHruid) {return 1} | ||||
|  |  | |||
		Reference in a new issue
	
	 Gerald Schmittinger
						Gerald Schmittinger