test: extra test (werkt nog niet)

This commit is contained in:
laurejablonski 2025-05-16 23:39:27 +02:00
parent c847851119
commit f6bf37b3bc
2 changed files with 34 additions and 1 deletions

View file

@ -0,0 +1,30 @@
import { describe, it, expect, beforeEach } from "vitest";
import { Language } from "@dwengo-1/common/util/language";
import { QuestionController } from "../../src/controllers/questions";
describe("QuestionController Tests", () => {
let controller: QuestionController;
beforeEach(() => {
const loiDTO = {
hruid: "u_test_multiple_choice",
language: Language.English,
version: 1,
};
controller = new QuestionController(loiDTO);
});
it("should fetch all questions", async () => {
const result = await controller.getAll(true);
expect(result).toHaveProperty("questions");
expect(Array.isArray(result.questions)).toBe(true);
expect(result.questions.length).toBeGreaterThan(0);
});
it("should fetch an question by sequencenumber", async () => {
const questionNumber = 1; // Example sequence number
const result = await controller.getBy(questionNumber);
expect(result).toHaveProperty("question");
expect(result.question).toHaveProperty("sequenceNumber", questionNumber);
});
});

View file

@ -1,5 +1,6 @@
import { spawn } from "child_process";
import { ChildProcess, spawnSync } from "node:child_process";
import { getLogger } from "../../backend/src/logging/initalize";
let backendProcess: ChildProcess;
@ -35,6 +36,8 @@ export async function setup(): Promise<void> {
export async function teardown(): Promise<void> {
if (backendProcess) {
backendProcess.kill();
while (!backendProcess.kill()) {
getLogger().error(`Failed to kill backend process! Retrying...`);
}
}
}