test: answer controller frontend
This commit is contained in:
		
							parent
							
								
									f6bf37b3bc
								
							
						
					
					
						commit
						ee96c8cb5f
					
				
					 1 changed files with 33 additions and 0 deletions
				
			
		
							
								
								
									
										33
									
								
								frontend/tests/controllers/answers-controller.test.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								frontend/tests/controllers/answers-controller.test.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,33 @@ | ||||||
|  | import { describe, it, expect, beforeEach } from "vitest"; | ||||||
|  | import { AnswerController } from "../../src/controllers/answers"; | ||||||
|  | import { Language } from "@dwengo-1/common/util/language"; | ||||||
|  | 
 | ||||||
|  | describe("AnswerController Tests", () => { | ||||||
|  |     let controller: AnswerController; | ||||||
|  | 
 | ||||||
|  |     beforeEach(() => { | ||||||
|  |         const loiDTO = { | ||||||
|  |             hruid: "u_test_multiple_choice", | ||||||
|  |             language: Language.English, | ||||||
|  |             version: 1, | ||||||
|  |         }; | ||||||
|  |         const questionId = { learningObjectIdentifier: loiDTO, sequenceNumber: 1 }; | ||||||
|  |         controller = new AnswerController(questionId); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("should fetch all answers", async () => { | ||||||
|  |         const result = await controller.getAll(true); | ||||||
|  |         expect(result).toHaveProperty("answers"); | ||||||
|  |         expect(Array.isArray(result.answers)).toBe(true); | ||||||
|  |         expect(result.answers.length).toBeGreaterThan(0); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("should fetch an answer by sequencenumber", async () => { | ||||||
|  |         const answerNumber = 1; // Example sequence number
 | ||||||
|  |         const result = await controller.getBy(answerNumber); | ||||||
|  |         expect(result).toHaveProperty("answer"); | ||||||
|  |         expect(result.answer).toHaveProperty("sequenceNumber", answerNumber); | ||||||
|  |     }); | ||||||
|  | }); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
		Reference in a new issue
	
	 laurejablonski
						laurejablonski