37 lines
1.0 KiB
TypeScript
37 lines
1.0 KiB
TypeScript
// Global setup that runs before any other setup
|
|
// This file must be loaded first to set up the window object
|
|
|
|
// Setup jsdom/happy-dom globals
|
|
// The test environment should provide window and document
|
|
if (typeof window !== "undefined") {
|
|
// Setup Tauri internals on window
|
|
Object.defineProperty(window, "__TAURI_OS_PLUGIN_INTERNALS__", {
|
|
writable: true,
|
|
configurable: true,
|
|
enumerable: true,
|
|
value: {
|
|
platform: "linux",
|
|
},
|
|
});
|
|
}
|
|
|
|
// Ensure document and window are available as globals (not just on globalThis)
|
|
if (typeof globalThis !== "undefined") {
|
|
if (typeof window !== "undefined" && !(global as any).window) {
|
|
(global as any).window = window;
|
|
}
|
|
|
|
if (typeof document !== "undefined" && !(global as any).document) {
|
|
(global as any).document = document;
|
|
}
|
|
|
|
// Also ensure they're on globalThis
|
|
if (typeof window !== "undefined" && !globalThis.window) {
|
|
(globalThis as any).window = window;
|
|
}
|
|
|
|
if (typeof document !== "undefined" && !globalThis.document) {
|
|
(globalThis as any).document = document;
|
|
}
|
|
}
|