1 | import { es } from "date-fns/locale/es";
|
2 |
|
3 | import { dateLib } from "../lib";
|
4 |
|
5 | import { getWeekdays } from "./getWeekdays";
|
6 |
|
7 | let result: Date[];
|
8 |
|
9 | describe("when rendered without a locale", () => {
|
10 | beforeEach(() => {
|
11 | result = getWeekdays();
|
12 | });
|
13 | test("should return 7 days", () => {
|
14 | expect(result).toHaveLength(7);
|
15 | });
|
16 | test("should return Sunday as first day", () => {
|
17 | expect(result[0]).toBeSunday();
|
18 | });
|
19 | });
|
20 |
|
21 | describe.each<0 | 1 | 2 | 3 | 4 | 5 | 6>([0, 1, 2, 3, 4, 5, 6])(
|
22 | "when week start on %s",
|
23 | (weekStartsOn) => {
|
24 | beforeEach(() => {
|
25 | result = getWeekdays(es, weekStartsOn);
|
26 | });
|
27 | test("the first date should be weekStartsOn", () => {
|
28 | expect(result[0].getDay()).toBe(weekStartsOn);
|
29 | });
|
30 | }
|
31 | );
|
32 |
|
33 | describe("when using ISO week", () => {
|
34 | beforeEach(() => {
|
35 | result = getWeekdays(es, 3, true, dateLib);
|
36 | });
|
37 | test("should return Monday as first day", () => {
|
38 | expect(result[0]).toBeMonday();
|
39 | });
|
40 | });
|