feat: voorbeeld test file
This commit is contained in:
		
							parent
							
								
									11023b1ef0
								
							
						
					
					
						commit
						2a7be32705
					
				
					 1 changed files with 32 additions and 0 deletions
				
			
		
							
								
								
									
										32
									
								
								backend/tests/service/learning-paths.test.ts
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										32
									
								
								backend/tests/service/learning-paths.test.ts
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,32 @@ | |||
| import { describe, it, expect, vi } from 'vitest'; | ||||
| import { fetchLearningPaths } from '../../src/services/learningPaths'; | ||||
| import { fetchWithLogging } from '../../src/util/apiHelper'; | ||||
| import { LearningPathResponse } from '../../src/interfaces/learningPath'; | ||||
| 
 | ||||
| 
 | ||||
| describe('fetchLearningPaths', () => { | ||||
|     const mockHruids = ['pn_werking', 'art1']; | ||||
|     const language = 'en'; | ||||
|     const source = 'Test Source'; | ||||
| 
 | ||||
|     it('✅ Moet een succesvolle response retourneren wanneer hruids zijn opgegeven', async () => { | ||||
|         // Mock response van fetchWithLogging
 | ||||
|         //const mockResponse = [{ title: 'Test Path', hruids: mockHruids }];
 | ||||
| 
 | ||||
|         const result: LearningPathResponse = await fetchLearningPaths(mockHruids, language, source); | ||||
| 
 | ||||
|         expect(result.success).toBe(true); | ||||
|         //expect(result.data).toEqual(mockResponse);
 | ||||
|         expect(result.source).toBe(source); | ||||
|     }); | ||||
| 
 | ||||
|     it('⚠️ Moet een foutmelding teruggeven als er geen hruids zijn opgegeven', async () => { | ||||
|         const result: LearningPathResponse = await fetchLearningPaths([], language, source); | ||||
| 
 | ||||
|         expect(result.success).toBe(false); | ||||
|         expect(result.data).toBeNull(); | ||||
|         expect(result.message).toBe(`No HRUIDs provided for ${source}.`); | ||||
|     }); | ||||
| 
 | ||||
| 
 | ||||
| }); | ||||
		Reference in a new issue
	
	 Gabriellvl
						Gabriellvl