import { describe, expect, it, vi } from "vitest"; // Mock the dependencies before importing the main module vi.mock("../CachedHandler", () => ({ default: class MockCachedHandler {}, })); vi.mock("../RedisStringsHandler", () => ({ default: class MockRedisStringsHandler {}, })); describe("Main index exports", () => { it("should export CachedHandler as default", async () => { const { default: CachedHandler } = await import("../index"); expect(CachedHandler).toBeDefined(); expect(typeof CachedHandler).toBe("function"); // Should be able to instantiate const handler = new CachedHandler({}); expect(handler).toBeInstanceOf(CachedHandler); }); it("should export RedisStringsHandler as named export", async () => { const { RedisStringsHandler } = await import("../index"); expect(RedisStringsHandler).toBeDefined(); expect(typeof RedisStringsHandler).toBe("function"); // Should be able to instantiate const handler = new RedisStringsHandler({}); expect(handler).toBeInstanceOf(RedisStringsHandler); }); it("should have both exports available", async () => { const exports = await import("../index"); expect(exports.default).toBeDefined(); expect(exports.RedisStringsHandler).toBeDefined(); // Verify they are different classes expect(exports.default).not.toBe(exports.RedisStringsHandler); }); it("should maintain compatibility with destructuring imports", async () => { const { default: DefaultHandler, RedisStringsHandler } = await import( "../index" ); expect(DefaultHandler).toBeDefined(); expect(RedisStringsHandler).toBeDefined(); // Both should be constructible const defaultHandler = new DefaultHandler({}); const redisHandler = new RedisStringsHandler({}); expect(defaultHandler).toBeDefined(); expect(redisHandler).toBeDefined(); }); it("should maintain compatibility with require-style imports", async () => { // Test namespace import const allExports = await import("../index"); expect(allExports.default).toBeDefined(); expect(allExports.RedisStringsHandler).toBeDefined(); // Should only have these two main exports const exportKeys = Object.keys(allExports); expect(exportKeys).toContain("default"); expect(exportKeys).toContain("RedisStringsHandler"); }); it("should provide TypeScript type information", async () => { // Import types to ensure they're properly exported const module = await import("../index"); // These should be available for TypeScript users expect(typeof module.default).toBe("function"); expect(typeof module.RedisStringsHandler).toBe("function"); }); });