hezarfen_frontend
Clone
https://git.tahinli.com/archive/hezarfen_frontend.git
0 watching0 forksTypeScript5.5 MiBdcf123aBurak Boduroğlu2 months ago674 commits
| 1 | import { MAX_PAGES, parsePages } from "@/lib/question-generation"; |
| 2 | |
| 3 | describe("parsePages", () => { |
| 4 | it("expands ranges and single pages, sorted and de-duplicated", () => { |
| 5 | expect(parsePages("3-5, 10, 4")).toEqual([3, 4, 5, 10]); |
| 6 | expect(parsePages(" 7 ")).toEqual([7]); |
| 7 | }); |
| 8 | |
| 9 | it("refuses anything that is not a page list", () => { |
| 10 | expect(parsePages("")).toBeNull(); |
| 11 | expect(parsePages("abc")).toBeNull(); |
| 12 | expect(parsePages("5-3")).toBeNull(); |
| 13 | expect(parsePages("0")).toBeNull(); |
| 14 | expect(parsePages("2,,x")).toBeNull(); |
| 15 | }); |
| 16 | |
| 17 | it("refuses more pages than one request may name", () => { |
| 18 | expect(parsePages(`1-${MAX_PAGES}`)).toHaveLength(MAX_PAGES); |
| 19 | expect(parsePages(`1-${MAX_PAGES + 1}`)).toBeNull(); |
| 20 | }); |
| 21 | }); |