test(frontend): Themes
This commit is contained in:
		
							parent
							
								
									5fb9866148
								
							
						
					
					
						commit
						4f9326e8cc
					
				
					 2 changed files with 48 additions and 18 deletions
				
			
		|  | @ -29,24 +29,6 @@ describe("Test controller teachers", () => { | ||||||
|         await expect(controller.getByUsername(username)).rejects.toThrow(); |         await expect(controller.getByUsername(username)).rejects.toThrow(); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it("Create a new teacher", async () => { |  | ||||||
|         const newTeacher = { |  | ||||||
|             username: "newteacher", |  | ||||||
|             firstName: "New", |  | ||||||
|             lastName: "Teacher", |  | ||||||
|         }; |  | ||||||
|         const data = await controller.createTeacher(newTeacher); |  | ||||||
|         expect(data.teacher.username).to.equal(newTeacher.username); |  | ||||||
|         expect(data.teacher.firstName).to.equal(newTeacher.firstName); |  | ||||||
|         expect(data.teacher.lastName).to.equal(newTeacher.lastName); |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
|     it("Delete a teacher", async () => { |  | ||||||
|         const username = "newteacher"; |  | ||||||
|         const data = await controller.deleteTeacher(username); |  | ||||||
|         expect(data).toBeTruthy(); |  | ||||||
|     }); |  | ||||||
| 
 |  | ||||||
|     it("Handle deletion of non-existent teacher", async () => { |     it("Handle deletion of non-existent teacher", async () => { | ||||||
|         const username = "nonexistentuser"; |         const username = "nonexistentuser"; | ||||||
|         await expect(controller.deleteTeacher(username)).rejects.toThrow(); |         await expect(controller.deleteTeacher(username)).rejects.toThrow(); | ||||||
|  |  | ||||||
							
								
								
									
										48
									
								
								frontend/tests/controllers/theme-controller.test.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								frontend/tests/controllers/theme-controller.test.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,48 @@ | ||||||
|  | import { describe, it, expect, beforeEach } from "vitest"; | ||||||
|  | import { ThemeController } from "../../src/controllers/themes"; | ||||||
|  | 
 | ||||||
|  | describe("ThemeController Tests", () => { | ||||||
|  |     let controller: ThemeController; | ||||||
|  | 
 | ||||||
|  |     beforeEach(() => { | ||||||
|  |         controller = new ThemeController(); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("should fetch all themes", async () => { | ||||||
|  |         const result = await controller.getAll(); | ||||||
|  |         expect(Array.isArray(result)).toBe(true); | ||||||
|  |         expect(result.length).toBeGreaterThan(0); | ||||||
|  |         expect(result[0]).toHaveProperty("key"); | ||||||
|  |         expect(result[0]).toHaveProperty("title"); | ||||||
|  |         expect(result[0]).toHaveProperty("description"); | ||||||
|  |         expect(result[0]).toHaveProperty("image"); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("should fetch all themes filtered by language", async () => { | ||||||
|  |         const language = "en"; | ||||||
|  |         const result = await controller.getAll(language); | ||||||
|  |         expect(Array.isArray(result)).toBe(true); | ||||||
|  |         expect(result.length).toBeGreaterThan(0); | ||||||
|  |         result.forEach((theme) => { | ||||||
|  |             expect(theme).toHaveProperty("key"); | ||||||
|  |             expect(theme).toHaveProperty("title"); | ||||||
|  |             expect(theme).toHaveProperty("description"); | ||||||
|  |             expect(theme).toHaveProperty("image"); | ||||||
|  |         }); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("should fetch HRUIDs by theme key", async () => { | ||||||
|  |         const themeKey = "kiks"; | ||||||
|  |         const result = await controller.getHruidsByKey(themeKey); | ||||||
|  |         expect(Array.isArray(result)).toBe(true); | ||||||
|  |         expect(result.length).toBeGreaterThan(0); | ||||||
|  |         result.forEach((hruid) => { | ||||||
|  |             expect(typeof hruid).toBe("string"); | ||||||
|  |         }); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("should handle fetching HRUIDs for a non-existent theme key", async () => { | ||||||
|  |         const themeKey = "nonexistent"; | ||||||
|  |         await expect(controller.getHruidsByKey(themeKey)).rejects.toThrow(); | ||||||
|  |     }); | ||||||
|  | }); | ||||||
		Reference in a new issue