UNPKG

@activecollab/components

Version:

ActiveCollab Components

16 lines 926 B
import { formatDate } from "./dateUtils"; describe("formatDate", function () { let dateNowSpy; beforeAll(() => { // Lock Time Fri, 07 Oct 2022 12:43:40 GMT dateNowSpy = jest.spyOn(Date, "now").mockImplementation(() => 1665146620336); }); afterAll(() => { // Unlock Time dateNowSpy.mockRestore(); }); it.each([[1660046717, "LL", true, "August 9, 2022"], [1660046717, "YYYY-MM-DD", true, "2022-08-09"], [new Date("2021-01-02"), "YYYY-MM-DD", true, "2021-01-02"], ["2021-01-02", "YYYY-MM-DD", true, "2021-01-02"], ["2021-01-02", "YYYY-MM-DD", false, "2021-01-02"], ["2022-01-02", "YYYY MM-DD", false, "01-02"], [1660046717, "MMMM. DD YYYY", false, "August. 09"], [1660046717, "MMMM. DD YYYY", true, "August. 09 2022"]])("should handle format Date", (value, format, long, expected) => { expect(formatDate(value, format, long)).toEqual(expected); }); }); //# sourceMappingURL=dateUtils.test.js.map