import { render } from "@testing-library/react"; import { axe, toHaveNoViolations } from "jest-axe"; import React from "react"; import DatePicker from "../index"; import { newDate, addDays } from "../date_utils"; expect.extend(toHaveNoViolations); describe("Accessibility Tests", () => { describe("Basic DatePicker", () => { it("should work with proper labeling", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work with placeholder", async () => { const { container } = render( , ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work with aria-label", async () => { const { container } = render( , ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work when disabled", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work when readonly", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); }); describe("Opened DatePicker", () => { it("should not have violations when calendar is open", async () => { // FAILING: ARIA structure issues - role="row" needs proper parent container const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work with inline calendar", async () => { // FAILING: ARIA structure issues - role="row" needs proper parent container const { container } = render(

Select a date

, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); }); describe("Date Range Picker", () => { it("should work with date range picker", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work with open range picker", async () => { // FAILING: ARIA structure issues - role="row" needs proper parent container const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); }); describe("Time Selection", () => { it("should work with time selection", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work with time input", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work with time only", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); }); describe("Month and Year Pickers", () => { it("should work with month picker", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work with year picker", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work with quarter picker", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); }); describe("Week Selection", () => { it("should work with week picker", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work with week numbers shown", async () => { // FAILING: ARIA children requirements - role="listbox" has incorrect child elements const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); }); describe("Multiple Months", () => { it("should work with multiple months", async () => { // FAILING: ARIA structure issues - role="row" needs proper parent container const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); }); describe("Custom Components", () => { it("should work with clear button", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work with calendar icon", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); }); describe("Edge Cases", () => { it("should work with no selected date", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); it("should work with portal", async () => { const { container } = render(
, ); const results = await axe(container); expect(results).toHaveNoViolations(); }); }); });