31 lines
905 B
TypeScript
31 lines
905 B
TypeScript
import { describe, it, expect, vi } from "vitest";
|
|
import { provideSSRWidth } from "@vueuse/core";
|
|
|
|
// Mock @vueuse/core
|
|
vi.mock("@vueuse/core", () => ({
|
|
provideSSRWidth: vi.fn(),
|
|
}));
|
|
|
|
describe("SSR Width Plugin", () => {
|
|
it("should call provideSSRWidth with 1024 and vueApp", async () => {
|
|
// Mock global defineNuxtPlugin
|
|
vi.stubGlobal("defineNuxtPlugin", (plugin: any) => plugin);
|
|
|
|
// Dynamic import to ensure global is set first
|
|
const { default: plugin } = await import("~/plugins/50-ssr-width");
|
|
|
|
const mockVueApp = {};
|
|
const mockNuxtApp = {
|
|
vueApp: mockVueApp,
|
|
};
|
|
|
|
// The plugin default export is the function passed to defineNuxtPlugin
|
|
// because of our mock above.
|
|
plugin(mockNuxtApp);
|
|
|
|
expect(provideSSRWidth).toHaveBeenCalledTimes(1);
|
|
expect(provideSSRWidth).toHaveBeenCalledWith(1024, mockVueApp);
|
|
|
|
vi.unstubAllGlobals();
|
|
});
|
|
});
|