forge
Explore
Log in

Don't you dare go Hollow

hezarfen_frontend

Clone
★ 0

0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits

exam-labels.test.ts27 lines, 1.1 KiBHistoryRawDownload
1import { expect, test } from "vitest";
2import { attemptLabel } from "./exam-labels";
3
4test("shows used/max when the exam caps attempts", () => {
5 expect(attemptLabel({ attempts_used: 1, attempt: 1 }, 3)).toBe("1 / 3");
6});
7
8test("unlimited attempts (max 0) falls back to the attempt count", () => {
9 expect(attemptLabel({ attempts_used: 2, attempt: 2 }, 0)).toBe("2");
10});
11
12test("no attempt data renders a dash", () => {
13 expect(attemptLabel({}, 3)).toBe("—");
14});
15
16test("exam kind labels: built-in, seeded Turkish keys, and custom fallback", async () => {
17 const { examKindLabel, isKnownExamKind } = await import("./exam-labels");
18 const t = (key: string) => `<${key}>`;
19 expect(examKindLabel("midterm", t)).toBe("<exams.kind.midterm>");
20 expect(examKindLabel("yazili", t)).toBe("<exams.kind.yazili>");
21 expect(examKindLabel("sozlu", t)).toBe("<exams.kind.oral>");
22 expect(examKindLabel("uygulama", t)).toBe("<exams.kind.uygulama>");
23 expect(examKindLabel("deneme", t)).toBe("deneme");
24 expect(examKindLabel("toString", t)).toBe("toString");
25 // Seeded keys stay renamable in settings.
26 expect(isKnownExamKind("yazili")).toBe(false);
27});