From 2a7be3270517e6a392364690646c80604fb4625f Mon Sep 17 00:00:00 2001 From: Gabriellvl Date: Tue, 11 Mar 2025 12:12:39 +0100 Subject: [PATCH] feat: voorbeeld test file --- backend/tests/service/learning-paths.test.ts | 32 ++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 backend/tests/service/learning-paths.test.ts diff --git a/backend/tests/service/learning-paths.test.ts b/backend/tests/service/learning-paths.test.ts new file mode 100644 index 00000000..6ac15213 --- /dev/null +++ b/backend/tests/service/learning-paths.test.ts @@ -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}.`); + }); + + +});