UNPKG

493 BPlain TextView Raw
1import { es } from "date-fns/locale/es";
2
3import { dateLib } from "../lib";
4
5import { formatCaption } from "./formatCaption";
6
7const date = new Date(2022, 10, 21);
8
9test("should return the formatted caption", () => {
10 expect(formatCaption(date, {}, dateLib)).toEqual("November 2022");
11});
12
13describe("when a locale is passed in", () => {
14 test("should format using the locale", () => {
15 expect(formatCaption(date, { locale: es }, dateLib)).toEqual(
16 "noviembre 2022"
17 );
18 });
19});