hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import type { HomeworkReportEntry } from "@/api/client"; |
| 2 | import { summarizeChildHomework } from "./child-homework"; |
| 3 | |
| 4 | const DAY = 24 * 60 * 60 * 1000; |
| 5 | const now = Date.UTC(2026, 8, 18, 9); |
| 6 | const entry = (id: string, due: number, state: Partial<HomeworkReportEntry> = {}): HomeworkReportEntry => ({ |
| 7 | class_course: "instance-1", |
| 8 | homework: id, |
| 9 | title: id, |
| 10 | subject: "subject-1", |
| 11 | due_at: due, |
| 12 | submitted: false, |
| 13 | late: false, |
| 14 | missing: false, |
| 15 | result: null, |
| 16 | ...state, |
| 17 | }); |
| 18 | |
| 19 | it("splits a report into missing work and work due this week", () => { |
| 20 | const summary = summarizeChildHomework( |
| 21 | [ |
| 22 | entry("in-two-days", now + 2 * DAY), |
| 23 | entry("missing-new", now - DAY, { missing: true }), |
| 24 | entry("tomorrow", now + DAY), |
| 25 | entry("missing-old", now - 5 * DAY, { missing: true }), |
| 26 | entry("handed-in", now + DAY, { submitted: true }), |
| 27 | entry("next-month", now + 30 * DAY), |
| 28 | ], |
| 29 | now, |
| 30 | ); |
| 31 | expect(summary.missing.map((row) => row.homework)).toEqual(["missing-old", "missing-new"]); |
| 32 | expect(summary.dueSoon.map((row) => row.homework)).toEqual(["tomorrow", "in-two-days"]); |
| 33 | }); |