/**
 * Tests for logging system
 */

import { logger } from "@/lib/logger";

describe("Logger", () => {
  it("should expose standard log methods", () => {
    expect(typeof logger.info).toBe("function");
    expect(typeof logger.warn).toBe("function");
    expect(typeof logger.error).toBe("function");
    expect(typeof logger.debug).toBe("function");
    expect(typeof logger.security).toBe("function");
  });

  it("should support scoped loggers", () => {
    const scopedLogger = logger.scope("TestService");
    expect(typeof scopedLogger.info).toBe("function");
    expect(typeof scopedLogger.warn).toBe("function");
    expect(typeof scopedLogger.error).toBe("function");
    expect(typeof scopedLogger.debug).toBe("function");
    expect(typeof scopedLogger.security).toBe("function");
  });

  it("should not throw when calling log methods", () => {
    expect(() => logger.info("test message")).not.toThrow();
    expect(() => logger.warn("test warning")).not.toThrow();
    expect(() => logger.error("test error", new Error("test"))).not.toThrow();
    expect(() => logger.debug("test debug")).not.toThrow();
    expect(() => logger.security("test security event")).not.toThrow();
  });

  it("should not throw when calling scoped log methods", () => {
    const scoped = logger.scope("Test");
    expect(() => scoped.info("test")).not.toThrow();
    expect(() => scoped.warn("test")).not.toThrow();
    expect(() => scoped.error("test", new Error("e"))).not.toThrow();
    expect(() => scoped.debug("test")).not.toThrow();
    expect(() => scoped.security("test")).not.toThrow();
  });

  it("should accept metadata in log methods", () => {
    expect(() => logger.info("test", { key: "value" })).not.toThrow();
    expect(() => logger.warn("test", { key: "value" })).not.toThrow();
    expect(() => logger.debug("test", { key: "value" })).not.toThrow();
  });
});
