hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits
| 1 | import { expect, test } from "vitest"; |
| 2 | import { examWeight } from "./exam-weight"; |
| 3 | |
| 4 | const kinds = [ |
| 5 | { name: "quiz", weight: 2 }, |
| 6 | { name: "final", weight: 5 }, |
| 7 | ]; |
| 8 | |
| 9 | test("a direct weight (marks report) wins over the settings lookup", () => { |
| 10 | expect(examWeight({ kind: "quiz", weight: 7 }, kinds)).toBe(7); |
| 11 | }); |
| 12 | |
| 13 | test("without a direct weight, the exam kind resolves through settings", () => { |
| 14 | expect(examWeight({ kind: "final" }, kinds)).toBe(5); |
| 15 | }); |
| 16 | |
| 17 | test("unknown kind and no weight yields null", () => { |
| 18 | expect(examWeight({ kind: "custom" }, kinds)).toBeNull(); |
| 19 | expect(examWeight({}, undefined)).toBeNull(); |
| 20 | }); |