import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { mediaContainer } from "@/di/container";
import { MEDIA_SYMBOLS } from "@/di/symbols";
import { MediaModule } from "@/di/module";
import { MockMediaRepository } from "@/infrastructure/repositories/media.repository.mock";
import type { IMediaRepository } from "@/application/repositories/media.repository.interface";

describe("mediaContainer", () => {
  beforeEach(() => {
    mediaContainer.unbindAll();
    mediaContainer.load(MediaModule);
  });

  afterEach(() => {
    mediaContainer.unbindAll();
  });

  it("resolves IMediaRepository to MockMediaRepository by default binding", () => {
    const repo = mediaContainer.get<IMediaRepository>(MEDIA_SYMBOLS.IMediaRepository);
    expect(repo).toBeInstanceOf(MockMediaRepository);
  });

  it("resolves IGetMediaController as a function", () => {
    const ctrl = mediaContainer.get(MEDIA_SYMBOLS.IGetMediaController);
    expect(typeof ctrl).toBe("function");
  });

  it("resolves IListMediaController as a function", () => {
    const ctrl = mediaContainer.get(MEDIA_SYMBOLS.IListMediaController);
    expect(typeof ctrl).toBe("function");
  });

  it("resolves IDeleteMediaController as a function", () => {
    const ctrl = mediaContainer.get(MEDIA_SYMBOLS.IDeleteMediaController);
    expect(typeof ctrl).toBe("function");
  });

  it("resolves IGetMediaUseCase as a function", () => {
    const uc = mediaContainer.get(MEDIA_SYMBOLS.IGetMediaUseCase);
    expect(typeof uc).toBe("function");
  });

  it("resolves IListMediaUseCase as a function", () => {
    const uc = mediaContainer.get(MEDIA_SYMBOLS.IListMediaUseCase);
    expect(typeof uc).toBe("function");
  });

  it("resolves IDeleteMediaUseCase as a function", () => {
    const uc = mediaContainer.get(MEDIA_SYMBOLS.IDeleteMediaUseCase);
    expect(typeof uc).toBe("function");
  });
});
