mirror of
https://github.com/n8n-io/n8n.git
synced 2025-01-23 10:32:17 -08:00
fix(editor): Use fake timers in useDebounce.test.ts to make the test less flaky (no-changelog) (#6029)
This commit is contained in:
parent
c3d19f52a2
commit
4037b3aeed
|
@ -3,7 +3,7 @@ import { useDebounceHelper } from '../useDebounce';
|
|||
import { render, screen } from '@testing-library/vue';
|
||||
|
||||
describe('useDebounceHelper', () => {
|
||||
const debounceTime = 200;
|
||||
const debounceTime = 500;
|
||||
|
||||
const TestComponent = {
|
||||
template: `
|
||||
|
@ -23,6 +23,7 @@ describe('useDebounceHelper', () => {
|
|||
},
|
||||
},
|
||||
setup() {
|
||||
vitest.useFakeTimers();
|
||||
const { callDebounced } = useDebounceHelper();
|
||||
return {
|
||||
callDebounced,
|
||||
|
@ -52,7 +53,7 @@ describe('useDebounceHelper', () => {
|
|||
|
||||
expect(mockFn).toHaveBeenCalledTimes(0);
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, debounceTime));
|
||||
vitest.advanceTimersByTime(debounceTime);
|
||||
|
||||
expect(mockFn).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue