evOo-local/apps/web/src/lib/performance.test.ts
cynarAI 6c7eed7580 Initial clean evOo-local from f00577b
Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline
(Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/*
packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
2026-09-20 17:15:16 +02:00

33 lines
1.0 KiB
TypeScript

import { beforeEach, describe, expect, it, vi } from "vitest";
import { markAfterPaint, markOnce } from "./performance";
describe("performance marks", () => {
beforeEach(() => {
performance.clearMarks();
});
it("records a named mark only once", () => {
markOnce("rk:test:once");
markOnce("rk:test:once");
expect(performance.getEntriesByName("rk:test:once")).toHaveLength(1);
});
it("records an after-paint mark after two animation frames", () => {
const callbacks: FrameRequestCallback[] = [];
vi.stubGlobal("requestAnimationFrame", (callback: FrameRequestCallback) => {
callbacks.push(callback);
return callbacks.length;
});
markAfterPaint("rk:test:painted");
expect(performance.getEntriesByName("rk:test:painted")).toHaveLength(0);
callbacks.shift()?.(1);
expect(performance.getEntriesByName("rk:test:painted")).toHaveLength(0);
callbacks.shift()?.(2);
expect(performance.getEntriesByName("rk:test:painted")).toHaveLength(1);
vi.unstubAllGlobals();
});
});