File size: 1,056 Bytes
cf86710
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { DateLib, type DayPickerLocale } from "../classes/DateLib.js";
import { getLabels } from "../helpers/getLabels.js";
import { enUS } from "../locale/en-US.js";
import { it } from "../locale/it.js";

import { labelNext } from "./labelNext";

test("returns the default label when no locale translation is provided", () => {
  expect(labelNext(new Date())).toEqual("Go to the Next Month");
});

test("returns the translated label from the locale when available", () => {
  const labels = getLabels(undefined, new DateLib({ locale: it }).options);

  expect(labels.labelNext(new Date())).toEqual("Vai al mese successivo");
});

test("calls the locale label function when provided", () => {
  const locale: DayPickerLocale = {
    ...enUS,
    labels: {
      labelNext: (month) =>
        month
          ? `Next: ${month.toLocaleDateString("en-US", { month: "long" })}`
          : "Next",
    },
  };

  const labels = getLabels(undefined, new DateLib({ locale }).options);

  expect(labels.labelNext(new Date(2022, 5, 1))).toEqual("Next: June");
});