murashit_codex-panel/tests/features/chat/ui/thread-stream/setup.ts
2026-07-09 06:52:13 +09:00

26 lines
757 B
TypeScript

import { beforeEach } from "vitest";
import { installObsidianDomShims } from "../../../../support/dom";
(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
installObsidianDomShims();
beforeEach(() => {
let nextAnimationFrameId = 1;
const callbacks = new Map<number, FrameRequestCallback>();
window.requestAnimationFrame = (callback) => {
const id = nextAnimationFrameId;
nextAnimationFrameId += 1;
callbacks.set(id, callback);
queueMicrotask(() => {
const scheduled = callbacks.get(id);
if (!scheduled) return;
callbacks.delete(id);
scheduled(0);
});
return id;
};
window.cancelAnimationFrame = (id) => {
callbacks.delete(id);
};
});