glowing-fiesta/tests/plugins/50-ssr-width.test.ts
Liviu Burcusel 0add58254d
All checks were successful
Production Build and Deploy / Build (push) Successful in 1m7s
Production Build and Deploy / Deploy (push) Successful in 21s
Project import from github
2026-01-14 16:29:05 +01:00

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();
});
});