import { afterEach, beforeEach, describe, expect, it } from "vitest";
import { blogContainer } from "./container";
import { BLOG_SYMBOLS } from "./symbols";
import { BlogModule } from "./module";
import { MockArticlesRepository } from "../infrastructure/repositories/articles.repository.mock";
import type { IArticlesRepository } from "../application/repositories/articles.repository.interface";

describe("blogContainer", () => {
  beforeEach(() => {
    blogContainer.unbindAll();
    blogContainer.load(BlogModule);
  });

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

  it("resolves IArticlesRepository to MockArticlesRepository by default binding", () => {
    const repo = blogContainer.get<IArticlesRepository>(
      BLOG_SYMBOLS.IArticlesRepository,
    );
    expect(repo).toBeInstanceOf(MockArticlesRepository);
  });

  it("resolves IGetArticlesController from the container", () => {
    const ctrl = blogContainer.get(BLOG_SYMBOLS.IGetArticlesController);
    expect(typeof ctrl).toBe("function");
  });

  it("resolves ICreateArticleController from the container", () => {
    const ctrl = blogContainer.get(BLOG_SYMBOLS.ICreateArticleController);
    expect(typeof ctrl).toBe("function");
  });

  it("resolves IGetArticleBySlugController from the container", () => {
    const ctrl = blogContainer.get(BLOG_SYMBOLS.IGetArticleBySlugController);
    expect(typeof ctrl).toBe("function");
  });
});
