From 8152306a9239db579dcbf6cb30b0ba4f7dbb9236 Mon Sep 17 00:00:00 2001 From: Gerald Schmittinger Date: Mon, 10 Mar 2025 21:59:12 +0100 Subject: [PATCH] test(backend): Testen voor DatabaseLearningPathProvider.searchLearningPath afgewerkt --- .../database-learning-path-provider.test.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) rename backend/tests/services/{learning-objects => learning-path}/database-learning-path-provider.test.ts (67%) diff --git a/backend/tests/services/learning-objects/database-learning-path-provider.test.ts b/backend/tests/services/learning-path/database-learning-path-provider.test.ts similarity index 67% rename from backend/tests/services/learning-objects/database-learning-path-provider.test.ts rename to backend/tests/services/learning-path/database-learning-path-provider.test.ts index 321fe213..5d612f04 100644 --- a/backend/tests/services/learning-objects/database-learning-path-provider.test.ts +++ b/backend/tests/services/learning-path/database-learning-path-provider.test.ts @@ -62,4 +62,32 @@ describe("DatabaseLearningPathProvider", () => { expect(result.success).toBe(false); }); }); + + describe("searchLearningPaths", () => { + it("returns the correct learning path when queried with a substring of its title", async () => { + const result = await databaseLearningPathProvider.searchLearningPaths( + example.learningPath.title.substring(2, 6), + example.learningPath.language + ); + expect(result.length).toBe(1); + expect(result[0].title).toBe(example.learningPath.title); + expect(result[0].description).toBe(example.learningPath.description); + }); + it("returns the correct learning path when queried with a substring of the description", async () => { + const result = await databaseLearningPathProvider.searchLearningPaths( + example.learningPath.description.substring(5, 12), + example.learningPath.language + ); + expect(result.length).toBe(1); + expect(result[0].title).toBe(example.learningPath.title); + expect(result[0].description).toBe(example.learningPath.description); + }); + it("returns an empty result when queried with a text which is not a substring of the title or the description of a learning path", async () => { + const result = await databaseLearningPathProvider.searchLearningPaths( + "substring which does not occur in the title or the description of a learning object", + example.learningPath.language + ); + expect(result.length).toBe(0); + }); + }); });