import { describe, test, expect } from "vitest"; import { render } from "@testing-library/react"; import { parseDate, now, getLocalTimeZone } from "@internationalized/date"; import { DateInput } from "."; describe("DateInput", () => { describe("matches snapshots", () => { const shared = { label: "Date Input", message: "Select a date", error: "Invalid date", onChange: () => {}, }; test("default variant", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("with value", () => { const result = render( ); expect(result.asFragment()).toMatchSnapshot(); }); test("with default value", () => { const result = render( ); expect(result.asFragment()).toMatchSnapshot(); }); test("day granularity", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("hour granularity", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("minute granularity", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("second granularity", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("disabled state", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("required state", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("readonly state", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("invalid state", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("with leading zeros", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("24 hour cycle", () => { const result = render( ); expect(result.asFragment()).toMatchSnapshot(); }); test("small size", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("medium size", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("large size", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); test("with min and max values", () => { const today = now(getLocalTimeZone()); const minValue = today.subtract({ days: 30 }); const maxValue = today.add({ days: 30 }); const result = render( ); expect(result.asFragment()).toMatchSnapshot(); }); test("without label", () => { const result = render( ); expect(result.asFragment()).toMatchSnapshot(); }); test("without message", () => { const result = render( ); expect(result.asFragment()).toMatchSnapshot(); }); test("without error", () => { const result = render( ); expect(result.asFragment()).toMatchSnapshot(); }); test("minimal props", () => { const result = render(); expect(result.asFragment()).toMatchSnapshot(); }); }); });