mirror of
https://github.com/getpaseo/paseo.git
synced 2026-07-29 12:01:31 +00:00
Add vitest.setup.ts to define __DEV__, shim Expo globals, mock react-native-unistyles/expo-linking, and stub @xterm/addon-ligatures. Update stale test expectations across combined-model-selector, use-settings, tool-call-display, sidebar-project-row-model, sidebar-shortcuts, keyboard-shortcuts, host-runtime, use-agent-form-state, desktop-permissions, and voice-runtime to match current source behavior. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
73 lines
1.6 KiB
TypeScript
73 lines
1.6 KiB
TypeScript
// @ts-nocheck
|
|
import { vi } from "vitest";
|
|
|
|
const globalWithTestShims = globalThis as typeof globalThis & Record<string, any>;
|
|
|
|
globalWithTestShims.__DEV__ = false;
|
|
|
|
if (typeof globalThis.self === "undefined") {
|
|
globalWithTestShims.self = globalThis;
|
|
}
|
|
|
|
if (typeof globalThis.expo === "undefined") {
|
|
class ExpoEventEmitter {
|
|
addListener() {
|
|
return {
|
|
remove() {},
|
|
};
|
|
}
|
|
removeListener() {}
|
|
removeAllListeners() {}
|
|
emit() {}
|
|
listenerCount() {
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
class ExpoSharedObject extends ExpoEventEmitter {}
|
|
class ExpoSharedRef extends ExpoSharedObject {}
|
|
class ExpoNativeModule extends ExpoEventEmitter {}
|
|
|
|
globalWithTestShims.expo = {
|
|
EventEmitter: ExpoEventEmitter,
|
|
SharedObject: ExpoSharedObject,
|
|
SharedRef: ExpoSharedRef,
|
|
NativeModule: ExpoNativeModule,
|
|
modules: {},
|
|
};
|
|
}
|
|
|
|
if (typeof globalThis.requestAnimationFrame !== "function") {
|
|
globalThis.requestAnimationFrame = (callback: FrameRequestCallback) =>
|
|
setTimeout(() => callback(Date.now()), 0) as unknown as number;
|
|
}
|
|
|
|
if (typeof globalThis.cancelAnimationFrame !== "function") {
|
|
globalThis.cancelAnimationFrame = (handle: number) => {
|
|
clearTimeout(handle);
|
|
};
|
|
}
|
|
|
|
vi.mock("react-native-unistyles", () => ({
|
|
StyleSheet: {
|
|
create: <T>(styles: T) => styles,
|
|
},
|
|
useUnistyles: () => ({
|
|
theme: {},
|
|
rt: {},
|
|
breakpoint: undefined,
|
|
}),
|
|
UnistylesRuntime: {
|
|
setTheme: vi.fn(),
|
|
themeName: "light",
|
|
},
|
|
}));
|
|
|
|
vi.mock("@xterm/addon-ligatures", () => ({
|
|
LigaturesAddon: class LigaturesAddon {},
|
|
}));
|
|
|
|
vi.mock("expo-linking", () => ({
|
|
openURL: vi.fn().mockResolvedValue(undefined),
|
|
}));
|