freshyo/apps/user-ui/tests/mocks/refresh.ts
2026-09-26 00:46:08 +05:30

27 lines
819 B
TypeScript

/**
* Capture for the refresh hooks.
*
* tests/setup.ts mocks common-ui/hooks/useManualRefresh and useMarkDataFetchers.
* Their real implementations need a navigation container and are irrelevant to
* most assertions, but the home page funnels its pull-to-refresh through them.
* The mocks record the latest callback here so a test can invoke the page's
* handleRefresh directly.
*
* The callbacks are re-registered on every render, so read them only after the
* page has mounted.
*/
export interface RefreshHooks {
manualRefresh: (() => void) | null
markDataFetchers: (() => void) | null
}
export const refreshHooks: RefreshHooks = {
manualRefresh: null,
markDataFetchers: null,
}
export function resetRefreshHooks() {
refreshHooks.manualRefresh = null
refreshHooks.markDataFetchers = null
}