import { render, screen } from "@testing-library/react";
import { expect, test, vi } from "vitest";
import { MultiValueAutocomplete } from "@/shared/ui/MultiValueAutocomplete.jsx";

test("keeps native required only while required multi-select has no value", () => {
  const props = {
    label: "支持区域",
    labels: { 1: "区域 1" },
    onChange: vi.fn(),
    options: ["1"],
    required: true
  };
  const { rerender } = render(<MultiValueAutocomplete {...props} value={[]} />);

  expect(screen.getByRole("combobox")).toBeRequired();

  rerender(<MultiValueAutocomplete {...props} value={["1"]} />);

  expect(screen.getByRole("combobox")).not.toBeRequired();
});
