hezarfen_frontend
Clone
https://git.tahinli.com/Hezarfen/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiB5fcd955Burak Boduroğlu2 months ago730 commits
| 1 | import { backTarget } from "./back-target"; |
| 2 | |
| 3 | const ROUTES = [ |
| 4 | "/", |
| 5 | "/exams", |
| 6 | "/exams/$id", |
| 7 | "/exams/$id/live", |
| 8 | "/instances/$id", |
| 9 | "/exam-room/$id", |
| 10 | "/courses", |
| 11 | "/management/classes", |
| 12 | "/management/classes/$id", |
| 13 | "/management/settings", |
| 14 | "/profile/$userId", |
| 15 | ]; |
| 16 | |
| 17 | it("goes from a detail page to its list", () => { |
| 18 | expect(backTarget("/exams/42", ROUTES)).toBe("/exams"); |
| 19 | expect(backTarget("/management/classes/7", ROUTES)).toBe("/management/classes"); |
| 20 | }); |
| 21 | |
| 22 | it("goes from a nested page to the record it belongs to", () => { |
| 23 | expect(backTarget("/exams/42/live", ROUTES)).toBe("/exams/42"); |
| 24 | }); |
| 25 | |
| 26 | it("uses the hub for details that have no list of their own", () => { |
| 27 | expect(backTarget("/instances/7", ROUTES)).toBe("/courses"); |
| 28 | expect(backTarget("/exam-room/3", ROUTES)).toBe("/exams"); |
| 29 | expect(backTarget("/profile/u-1", ROUTES)).toBe("/"); |
| 30 | }); |
| 31 | |
| 32 | it("falls back to home when no ancestor route exists", () => { |
| 33 | expect(backTarget("/management/settings", ROUTES)).toBe("/"); |
| 34 | expect(backTarget("/exams", ROUTES)).toBe("/"); |
| 35 | }); |