UNPKG

@activecollab/components

Version:

ActiveCollab Components

20 lines (19 loc) 1 kB
"use strict"; var _dateUtils = require("./dateUtils"); describe("formatDate", function () { var dateNowSpy; beforeAll(function () { // Lock Time Fri, 07 Oct 2022 12:43:40 GMT dateNowSpy = jest.spyOn(Date, "now").mockImplementation(function () { return 1665146620336; }); }); afterAll(function () { // 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", function (value, format, long, expected) { expect((0, _dateUtils.formatDate)(value, format, long)).toEqual(expected); }); }); //# sourceMappingURL=dateUtils.test.js.map