hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { expect, test } from "vitest"; |
| 2 | import { attemptLabel } from "./exam-labels"; |
| 3 | |
| 4 | test("shows used/max when the exam caps attempts", () => { |
| 5 | expect(attemptLabel({ attempts_used: 1, attempt: 1 }, 3)).toBe("1 / 3"); |
| 6 | }); |
| 7 | |
| 8 | test("unlimited attempts (max 0) falls back to the attempt count", () => { |
| 9 | expect(attemptLabel({ attempts_used: 2, attempt: 2 }, 0)).toBe("2"); |
| 10 | }); |
| 11 | |
| 12 | test("no attempt data renders a dash", () => { |
| 13 | expect(attemptLabel({}, 3)).toBe("—"); |
| 14 | }); |
| 15 | |
| 16 | test("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 | }); |