delete-draft-flow.helpers.ts903 BView on GitHub /**
* Module-level spy state for `drafts.delete` mocking in
* `delete-draft-flow.test.tsx`.
*
* Jest hoists `jest.mock(...)` factories above the test file's local
* declarations, so the factory cannot capture test-scope variables. Stashing
* mutable state on a sibling module lets the mock factory (via `require`) and
* the test body share a single object without the hoisting hazard.
*/
interface DraftDeleteCall {
draftId?: string | null;
emailHeaderMessageId?: string | null;
threadId?: string;
}
interface DraftDeleteSpy {
calls: DraftDeleteCall[];
mode: 'resolve' | 'reject';
error?: Error;
}
const spy: DraftDeleteSpy = {
calls: [],
mode: 'resolve',
error: undefined,
};
export function __getDraftDeleteSpy(): DraftDeleteSpy {
return spy;
}
export function __resetDraftDeleteSpy(): void {
spy.calls.length = 0;
spy.mode = 'resolve';
spy.error = undefined;
}