import { describe, it, expect, vi, beforeEach } from "vitest"; import { createVuetify } from "vuetify"; import * as components from "vuetify/components"; import * as directives from "vuetify/directives"; // Mock the CSS imports since they're not needed for testing vi.mock("@mdi/font/css/materialdesignicons.css", () => ({})); vi.mock("vuetify/styles", () => ({})); // Mock createVuetify to spy on its calls vi.mock("vuetify", () => ({ createVuetify: vi.fn(), })); // Mock the components and directives vi.mock("vuetify/components", () => ({ VApp: {}, VBtn: {}, // Add other components as needed for your tests })); vi.mock("vuetify/directives", () => ({ vRipple: {}, vTooltip: {}, // Add other directives as needed for your tests })); describe("Vuetify Plugin Configuration", () => { const mockVuetifyInstance = { theme: { current: { value: { dark: true } }, global: { name: { value: "dark" } }, }, defaults: {}, display: {}, locale: {}, rtl: {}, }; beforeEach(() => { vi.clearAllMocks(); (createVuetify as any).mockReturnValue(mockVuetifyInstance); }); it("should create vuetify instance with correct configuration", async () => { // Import the module to trigger the createVuetify call await import("../../src/plugins/vuetify"); expect(createVuetify).toHaveBeenCalledTimes(1); expect(createVuetify).toHaveBeenCalledWith({ components, directives, theme: { defaultTheme: "dark", }, }); const callArgs = (createVuetify as any).mock.calls[0][0]; expect(callArgs.theme).toBeDefined(); expect(callArgs.theme.defaultTheme).toBe("dark"); expect(callArgs.components).toBe(components); expect(callArgs.directives).toBe(directives); const expectedKeys = ["components", "directives", "theme"]; const actualKeys = Object.keys(callArgs); expect([...actualKeys].sort((a, b) => a.localeCompare(b))).toEqual([...expectedKeys].sort((a, b) => a.localeCompare(b))); }); it("should export the vuetify instance", async () => { const vuetifyModule = await import("../../src/plugins/vuetify"); expect(vuetifyModule.default).toBeDefined(); expect(vuetifyModule.default).toBe(mockVuetifyInstance); }); it("should have proper module structure", () => { // Test that the required dependencies are properly structured expect(components).toBeDefined(); expect(directives).toBeDefined(); expect(typeof createVuetify).toBe("function"); }); describe("CSS imports", () => { it("should import Material Design Icons CSS", () => { // Since we're mocking the CSS import, we just verify it doesn't throw expect(() => { require("@mdi/font/css/materialdesignicons.css"); }).not.toThrow(); }); it("should import Vuetify styles", () => { // Since we're mocking the CSS import, we just verify it doesn't throw expect(() => { require("vuetify/styles"); }).not.toThrow(); }); }); });