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 type { HomeworkRosterEntry } from "@/api/client"; |
| 3 | import { defaultGradeStatus } from "./homework-grade"; |
| 4 | |
| 5 | const submission = {} as NonNullable<HomeworkRosterEntry["submission"]>; |
| 6 | const result = (status: string) => ({ status }) as NonNullable<HomeworkRosterEntry["result"]>; |
| 7 | |
| 8 | test("a saved result wins", () => { |
| 9 | expect(defaultGradeStatus({ result: result("incomplete"), missing: true, submission: null })).toBe("incomplete"); |
| 10 | }); |
| 11 | |
| 12 | test("a non-submitter past the deadline defaults to missing", () => { |
| 13 | expect(defaultGradeStatus({ result: null, missing: true, submission: null })).toBe("missing"); |
| 14 | }); |
| 15 | |
| 16 | test("a submitter defaults to done", () => { |
| 17 | expect(defaultGradeStatus({ result: null, missing: false, submission })).toBe("done"); |
| 18 | }); |
| 19 | |
| 20 | test("a non-submitter before the deadline has no default", () => { |
| 21 | expect(defaultGradeStatus({ result: null, missing: false, submission: null })).toBe(""); |
| 22 | }); |