mirror of
https://github.com/formbricks/formbricks.git
synced 2026-03-09 02:00:12 -05:00
Co-authored-by: Piyush Gupta <piyushguptaa2z123@gmail.com> Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
46 lines
904 B
TypeScript
46 lines
904 B
TypeScript
import { beforeEach, vi } from "vitest";
|
|
|
|
// Create a minimal window mock
|
|
const windowMock = {
|
|
document: {
|
|
createElement: vi.fn(() => ({
|
|
setAttribute: vi.fn(),
|
|
style: {},
|
|
})),
|
|
head: {
|
|
appendChild: vi.fn(),
|
|
},
|
|
body: {
|
|
appendChild: vi.fn(),
|
|
},
|
|
getElementById: vi.fn(),
|
|
},
|
|
localStorage: {
|
|
getItem: vi.fn(),
|
|
setItem: vi.fn(),
|
|
removeItem: vi.fn(),
|
|
clear: vi.fn(),
|
|
length: 0,
|
|
key: vi.fn(),
|
|
},
|
|
location: {
|
|
search: "formbricksDebug=true",
|
|
protocol: "https:",
|
|
host: "formbricks.com",
|
|
pathname: "/",
|
|
},
|
|
setInterval: vi.fn(),
|
|
clearInterval: vi.fn(),
|
|
};
|
|
|
|
// Stub globals
|
|
vi.stubGlobal("window", windowMock);
|
|
vi.stubGlobal("document", windowMock.document);
|
|
vi.stubGlobal("localStorage", windowMock.localStorage);
|
|
|
|
// Clear mocks between tests
|
|
beforeEach(() => {
|
|
vi.resetModules();
|
|
vi.clearAllMocks();
|
|
});
|