"use strict";
const locale = require("date-fns/locale");
const dateTimeInput_utils = require("./dateTimeInput.utils.cjs");
describe("minMaxCheckThrow", () => {
  it("should not throw an error when min date is before max date", () => {
    const minDate = /* @__PURE__ */ new Date("2023-01-01");
    const maxDate = /* @__PURE__ */ new Date("2023-12-31");
    expect(() => dateTimeInput_utils.minMaxCheckThrow(minDate, maxDate)).not.toThrow();
  });
  it("should not throw an error when min date and max date are the same", () => {
    const date = /* @__PURE__ */ new Date("2023-06-05");
    expect(() => dateTimeInput_utils.minMaxCheckThrow(date, date)).not.toThrow();
  });
  it("should throw an error when max date is before min date", () => {
    const minDate = /* @__PURE__ */ new Date("2023-12-31");
    const maxDate = /* @__PURE__ */ new Date("2023-01-01");
    expect(() => dateTimeInput_utils.minMaxCheckThrow(minDate, maxDate)).toThrow("Min date cannot be before max date!");
  });
  it("should not throw an error when either min date or max date is not provided", () => {
    const date = /* @__PURE__ */ new Date("2023-06-05");
    expect(() => dateTimeInput_utils.minMaxCheckThrow(void 0, date)).not.toThrow();
    expect(() => dateTimeInput_utils.minMaxCheckThrow(date, void 0)).not.toThrow();
    expect(() => dateTimeInput_utils.minMaxCheckThrow(void 0, void 0)).not.toThrow();
  });
});
describe("getMonths", () => {
  const locale$1 = locale.enGB;
  it("should return an array of 12 months for a valid year", () => {
    const year = 2023;
    const months = dateTimeInput_utils.getMonths(year, locale$1);
    expect(months).toHaveLength(12);
    expect(months[0].name).toBe("January");
    expect(months[1].name).toBe("February");
    expect(months[2].name).toBe("March");
    expect(months[3].name).toBe("April");
    expect(months[4].name).toBe("May");
    expect(months[5].name).toBe("June");
    expect(months[6].name).toBe("July");
    expect(months[7].name).toBe("August");
    expect(months[8].name).toBe("September");
    expect(months[9].name).toBe("October");
    expect(months[10].name).toBe("November");
    expect(months[11].name).toBe("December");
  });
  it("should disable months before the min date", () => {
    const year = 2023;
    const minDate = /* @__PURE__ */ new Date("2023-03-01");
    const months = dateTimeInput_utils.getMonths(year, locale$1, minDate);
    expect(months[0].disabled).toBe(true);
    expect(months[1].disabled).toBe(true);
    expect(months[2].disabled).toBe(false);
    expect(months[3].disabled).toBe(false);
    expect(months[4].disabled).toBe(false);
    expect(months[5].disabled).toBe(false);
    expect(months[6].disabled).toBe(false);
    expect(months[7].disabled).toBe(false);
    expect(months[8].disabled).toBe(false);
    expect(months[9].disabled).toBe(false);
    expect(months[10].disabled).toBe(false);
    expect(months[11].disabled).toBe(false);
  });
  it("should disable months after the max date", () => {
    const year = 2023;
    const maxDate = /* @__PURE__ */ new Date("2023-08-01");
    const months = dateTimeInput_utils.getMonths(year, locale$1, void 0, maxDate);
    expect(months[0].disabled).toBe(false);
    expect(months[1].disabled).toBe(false);
    expect(months[2].disabled).toBe(false);
    expect(months[3].disabled).toBe(false);
    expect(months[4].disabled).toBe(false);
    expect(months[5].disabled).toBe(false);
    expect(months[6].disabled).toBe(false);
    expect(months[7].disabled).toBe(false);
    expect(months[8].disabled).toBe(true);
    expect(months[9].disabled).toBe(true);
    expect(months[10].disabled).toBe(true);
    expect(months[11].disabled).toBe(true);
  });
  it("should disable months before the min date and after the max date", () => {
    const year = 2023;
    const minDate = /* @__PURE__ */ new Date("2023-03-01");
    const maxDate = /* @__PURE__ */ new Date("2023-08-01");
    const months = dateTimeInput_utils.getMonths(year, locale$1, minDate, maxDate);
    expect(months[0].disabled).toBe(true);
    expect(months[1].disabled).toBe(true);
    expect(months[2].disabled).toBe(false);
    expect(months[3].disabled).toBe(false);
    expect(months[4].disabled).toBe(false);
    expect(months[5].disabled).toBe(false);
    expect(months[6].disabled).toBe(false);
    expect(months[7].disabled).toBe(false);
    expect(months[8].disabled).toBe(true);
    expect(months[9].disabled).toBe(true);
    expect(months[10].disabled).toBe(true);
    expect(months[11].disabled).toBe(true);
  });
});
describe("getYears", () => {
  it("should return an array of years from default min year to default max year", () => {
    const years = dateTimeInput_utils.getYears();
    expect(years).toHaveLength(201);
    expect(years[0]).toBe(1900);
    expect(years[200]).toBe(2100);
  });
  it("should return an array of years from min year to default max year", () => {
    const minDate = /* @__PURE__ */ new Date("2000-01-01");
    const years = dateTimeInput_utils.getYears(minDate);
    expect(years).toHaveLength(101);
    expect(years[0]).toBe(2e3);
    expect(years[100]).toBe(2100);
  });
  it("should return an array of years from default min year to max year", () => {
    const maxDate = /* @__PURE__ */ new Date("2050-01-01");
    const years = dateTimeInput_utils.getYears(void 0, maxDate);
    expect(years).toHaveLength(151);
    expect(years[0]).toBe(1900);
    expect(years[150]).toBe(2050);
  });
  it("should return an array of years from min year to max year", () => {
    const minDate = /* @__PURE__ */ new Date("2000-01-01");
    const maxDate = /* @__PURE__ */ new Date("2050-01-01");
    const years = dateTimeInput_utils.getYears(minDate, maxDate);
    expect(years).toHaveLength(51);
    expect(years[0]).toBe(2e3);
    expect(years[50]).toBe(2050);
  });
});
describe("formatDate", () => {
  it("should format a valid date", () => {
    const date = /* @__PURE__ */ new Date("2023-06-05");
    const formatString = "yyyy-MM-dd";
    const formattedDate = dateTimeInput_utils.formatDate(date, formatString);
    expect(formattedDate).toBe("2023-06-05");
  });
  it("should return undefined for a null date", () => {
    const date = null;
    const formatString = "yyyy-MM-dd";
    const formattedDate = dateTimeInput_utils.formatDate(date, formatString);
    expect(formattedDate).toBeUndefined();
  });
  it("should return undefined for an undefined date", () => {
    const date = void 0;
    const formatString = "yyyy-MM-dd";
    const formattedDate = dateTimeInput_utils.formatDate(date, formatString);
    expect(formattedDate).toBeUndefined();
  });
  it("should handle a custom format string", () => {
    const date = /* @__PURE__ */ new Date("2023-06-05");
    const formatString = "MMM d, yyyy";
    const formattedDate = dateTimeInput_utils.formatDate(date, formatString);
    expect(formattedDate).toBe("Jun 5, 2023");
  });
});
//# sourceMappingURL=dateTimeInput.utils.spec.cjs.map
