mirror of
https://github.com/Horizontal42/summarum.git
synced 2026-11-10 15:42:01 +03:00
fix flaky debounce test: poll with real timers instead of guessing tick count
This commit is contained in:
parent
59df3a7264
commit
d08d807961
1 changed files with 7 additions and 5 deletions
|
|
@ -191,12 +191,14 @@ describe('storage', () => {
|
|||
// Fast forward past debounce time
|
||||
vi.runAllTimers();
|
||||
|
||||
// Allow dynamic import and promise resolution by temporarily using real timers
|
||||
// storage.ts's invoke wrapper does a dynamic import() before calling
|
||||
// invoke(), which resolves over real event-loop ticks (module
|
||||
// transform/IO) even with fake timers active — poll with real timers
|
||||
// until it settles instead of guessing a fixed number of ticks.
|
||||
vi.useRealTimers();
|
||||
await new Promise(resolve => setTimeout(resolve, 0));
|
||||
vi.useFakeTimers();
|
||||
|
||||
expect(invoke).toHaveBeenCalledWith('save_documents', { dir: 'custom_dir', contents: JSON.stringify(mockAppData) });
|
||||
await vi.waitFor(() => {
|
||||
expect(invoke).toHaveBeenCalledWith('save_documents', { dir: 'custom_dir', contents: JSON.stringify(mockAppData) });
|
||||
});
|
||||
});
|
||||
|
||||
it('flushAppData clears timer and saves immediately', async () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue