UNPKG

961 BPlain TextView Raw
1import { es } from "date-fns/locale/es";
2
3import { dateLib } from "../lib";
4
5import { getWeekdays } from "./getWeekdays";
6
7let result: Date[];
8
9describe("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
21describe.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
33describe("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});