import { describe, expect, it } from "vitest";
import { normalizeMediaUrl } from "../src/lib/media";

describe("normalizeMediaUrl", () => {
  it("normalizes YouTube watch urls", () => {
    const media = normalizeMediaUrl("https://www.youtube.com/watch?v=abc123");
    expect(media.provider).toBe("YOUTUBE");
    expect(media.playbackUrl).toContain("/embed/abc123");
  });

  it("normalizes Twitch channels", () => {
    const media = normalizeMediaUrl("https://www.twitch.tv/example");
    expect(media.provider).toBe("TWITCH");
    expect(media.playbackUrl).toContain("channel=example");
  });

  it("detects direct video sources", () => {
    const media = normalizeMediaUrl("https://cdn.example.com/video.mp4");
    expect(media.provider).toBe("DIRECT");
    expect(media.playbackUrl).toBe("https://cdn.example.com/video.mp4");
  });
});
