mirror of
https://github.com/hanzoai/insights-js.git
synced 2026-11-02 14:31:14 +00:00
* fix(llma): missing tool call in Anthropic streaming output * fix(llma): missing tool call in Gemini streaming output * fix(llma): missing tool call in OpenAI Completions API streaming output * fix(llma): missing $ai_tools for Vercel * fix(llma): missing tool call in Vercel streaming output * chore(llma): run linter * chore(llma): apply feedback * chore(llma): run linter
26 lines
696 B
TypeScript
26 lines
696 B
TypeScript
/**
|
|
* Test utilities for async operations
|
|
*/
|
|
|
|
/**
|
|
* Waits for async operations to complete
|
|
* Uses process.nextTick to ensure all microtasks are processed
|
|
*/
|
|
export async function waitForAsyncOperations(): Promise<void> {
|
|
// Use process.nextTick to wait for all microtasks
|
|
await new Promise(process.nextTick)
|
|
// If fake timers are enabled, run them and flush again
|
|
if (jest.isMockFunction(setTimeout)) {
|
|
jest.runAllTimers()
|
|
await new Promise(process.nextTick)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Alternative helper for tests that don't use fake timers
|
|
* but still need to wait for async operations
|
|
*/
|
|
export async function flushPromises(): Promise<void> {
|
|
await new Promise(process.nextTick)
|
|
}
|