import { describe, expect, it } from "vitest"
import { mount } from "@vue/test-utils"
import AutoCompleteOption from "./AutoCompleteOption.vue"

describe("AutoCompleteOption (props-based composition)", () => {
  it("mounts without error", () => {
    const wrapper = mount(AutoCompleteOption, { props: { label: "City" } })
    expect(wrapper.exists()).toBe(true)
  })

  it("renders the label via FieldFrame", () => {
    const wrapper = mount(AutoCompleteOption, {
      props: { label: "Custom label" },
    })
    expect(wrapper.text()).toContain("Custom label")
  })

  it("hides the visible label when hideLabel is true", () => {
    const wrapper = mount(AutoCompleteOption, {
      props: { label: "Hidden", hideLabel: true },
    })
    expect(wrapper.find("[data-testid='field-frame-label-sr']").exists()).toBe(
      true,
    )
  })

  it("renders help text", () => {
    const wrapper = mount(AutoCompleteOption, {
      props: { label: "X", helpText: "Search hint" },
    })
    expect(wrapper.find("[data-testid='field-frame-help']").text()).toBe(
      "Search hint",
    )
  })

  it("renders errors when provided", () => {
    const wrapper = mount(AutoCompleteOption, {
      props: { label: "X", errors: ["Required"] },
    })
    expect(wrapper.find("[data-testid='field-frame-errors']").exists()).toBe(
      true,
    )
  })

  it("works without any props at all", () => {
    const wrapper = mount(AutoCompleteOption)
    expect(wrapper.exists()).toBe(true)
  })
})
