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

describe("ModalBlock", () => {
  it("mounts without error", () => {
    const wrapper = mount(ModalBlock)
    expect(wrapper.exists()).toBe(true)
  })

  it("renders the default label", () => {
    const wrapper = mount(ModalBlock)
    expect(wrapper.text()).toContain("Modal")
  })

  it("renders the triggerLabel prop when provided", () => {
    const wrapper = mount(ModalBlock, {
      props: { triggerLabel: "Open settings" },
    })
    expect(wrapper.text()).toContain("Open settings")
  })

  it("renders the style key as a badge", () => {
    const wrapper = mount(ModalBlock)
    expect(wrapper.text()).toContain("modal")
  })

  it("exposes the data-stub attribute on the trigger", () => {
    const wrapper = mount(ModalBlock)
    expect(wrapper.find("[data-stub]").attributes("data-stub")).toBe(
      "configuration-block/modal",
    )
  })
})
