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

describe("VideoPlayerDisplay", () => {
  it("renders a video element with the given src and controls", () => {
    const wrapper = mount(VideoPlayerDisplay, {
      props: { src: "https://example.com/movie.mp4" },
    })
    const video = wrapper.find("video")
    expect(video.exists()).toBe(true)
    expect(video.attributes("src")).toBe("https://example.com/movie.mp4")
    expect(video.attributes("controls")).toBeDefined()
  })

  it("does not render a video when src is missing", () => {
    const wrapper = mount(VideoPlayerDisplay, { props: {} })
    expect(wrapper.find("video").exists()).toBe(false)
  })

  it("applies autoplay / loop / muted attributes when enabled", () => {
    const wrapper = mount(VideoPlayerDisplay, {
      props: {
        src: "https://example.com/movie.mp4",
        autoplay: true,
        loop: true,
        muted: true,
      },
    })
    const video = wrapper.find("video").element as HTMLVideoElement
    expect(video.autoplay).toBe(true)
    expect(video.loop).toBe(true)
    expect(video.muted).toBe(true)
  })

  it("omits autoplay / loop / muted by default", () => {
    const wrapper = mount(VideoPlayerDisplay, {
      props: { src: "https://example.com/movie.mp4" },
    })
    const video = wrapper.find("video").element as HTMLVideoElement
    expect(video.autoplay).toBe(false)
    expect(video.loop).toBe(false)
    expect(video.muted).toBe(false)
  })

  it("applies classList to the root", () => {
    const wrapper = mount(VideoPlayerDisplay, {
      props: { src: "x", classList: "framed" },
    })
    expect(wrapper.attributes("class")).toContain("framed")
  })
})
