hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { describe, expect, test } from "vitest"; |
| 2 | import { hhmmToMinutes, minutesToHHmm, sortSlots, weekdayLabel } from "./weekly-plan"; |
| 3 | |
| 4 | describe("weekly plan helpers", () => { |
| 5 | test("minutes and HH:mm round-trip", () => { |
| 6 | expect(minutesToHHmm(540)).toBe("09:00"); |
| 7 | expect(minutesToHHmm(0)).toBe("00:00"); |
| 8 | expect(hhmmToMinutes("09:40")).toBe(580); |
| 9 | expect(hhmmToMinutes("9:05")).toBe(545); |
| 10 | expect(hhmmToMinutes("24:00")).toBeNull(); |
| 11 | expect(hhmmToMinutes("09:60")).toBeNull(); |
| 12 | expect(hhmmToMinutes("nine")).toBeNull(); |
| 13 | }); |
| 14 | |
| 15 | test("weekday 1 is Monday and 7 is Sunday", () => { |
| 16 | expect(weekdayLabel(1, "en")).toBe("Monday"); |
| 17 | expect(weekdayLabel(7, "en")).toBe("Sunday"); |
| 18 | expect(weekdayLabel(1, "tr")).toBe("Pazartesi"); |
| 19 | }); |
| 20 | |
| 21 | test("slots sort by weekday, then start", () => { |
| 22 | const slot = (id: string, weekday: number, starts_at: number) => ({ id, weekday, starts_at, ends_at: starts_at + 40 }); |
| 23 | expect(sortSlots([slot("c", 2, 540), slot("b", 1, 600), slot("a", 1, 540)]).map((s) => s.id)).toEqual(["a", "b", "c"]); |
| 24 | }); |
| 25 | }); |