parent
7b34c27290
commit
0cec9f5afd
123 changed files with 4685 additions and 3607 deletions
31
tests/plugins/50-ssr-width.test.ts
Normal file
31
tests/plugins/50-ssr-width.test.ts
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
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();
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue