mirror of
https://github.com/anomalyco/opencode.git
synced 2026-08-06 08:09:57 +00:00
test(app): stabilize reconnect offset timing
This commit is contained in:
parent
232ee3b10d
commit
a81628ebfe
1 changed files with 6 additions and 2 deletions
|
|
@ -45,8 +45,7 @@ test("reports a divergent native offset once and ignores equal offsets and unrel
|
|||
|
||||
route.remove()
|
||||
document.body.append(route)
|
||||
await new Promise((resolve) => setTimeout(resolve, 0))
|
||||
await frames(3)
|
||||
await waitFor(() => calls.length === 1)
|
||||
expect(calls).toEqual([[0, false]])
|
||||
|
||||
route.remove()
|
||||
|
|
@ -197,3 +196,8 @@ async function frames(count: number) {
|
|||
await new Promise<void>((resolve) => requestAnimationFrame(() => resolve()))
|
||||
}
|
||||
}
|
||||
|
||||
async function waitFor(condition: () => boolean) {
|
||||
const deadline = performance.now() + 1_000
|
||||
while (!condition() && performance.now() < deadline) await frames(1)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue