| | import { toGregorianDate } from "../utils"; |
| |
|
| | import { getWeek } from "./getWeek"; |
| |
|
| | describe("getWeek", () => { |
| | test("should return 1 for first week of year", () => { |
| | const date = toGregorianDate({ |
| | year: 2016, |
| | month: 1, |
| | day: 1, |
| | }); |
| | expect(getWeek(date)).toBe(1); |
| | }); |
| |
|
| | test("should handle dates in last month of year to be either 52 or 1", () => { |
| | |
| | const date52 = toGregorianDate({ |
| | year: 2016, |
| | month: 13, |
| | day: 1, |
| | }); |
| | expect(getWeek(date52)).toBe(52); |
| |
|
| | |
| | const date1 = toGregorianDate({ |
| | year: 2016, |
| | month: 13, |
| | day: 5, |
| | }); |
| | expect(getWeek(date1)).toBe(1); |
| | }); |
| |
|
| | test("should handle dates at week boundaries", () => { |
| | |
| | const sunday = toGregorianDate({ |
| | year: 2016, |
| | month: 1, |
| | day: 6, |
| | }); |
| | expect(getWeek(sunday)).toBe(1); |
| |
|
| | |
| | const monday = toGregorianDate({ |
| | year: 2016, |
| | month: 1, |
| | day: 7, |
| | }); |
| | expect(getWeek(monday)).toBe(2); |
| | }); |
| |
|
| | test("should handle dates in middle of year", () => { |
| | const midYear = toGregorianDate({ |
| | year: 2016, |
| | month: 6, |
| | day: 15, |
| | }); |
| | expect(getWeek(midYear)).toBe(24); |
| | }); |
| | }); |
| |
|