test: optimize useSelectionList tests with fake timers

This commit is contained in:
mkorwel
2026-04-20 22:09:14 +00:00
parent 0a933c7ff1
commit a3024f3eed
@@ -38,6 +38,7 @@ describe('useSelectionList', () => {
];
beforeEach(() => {
vi.useFakeTimers();
activeKeypressHandler = null;
vi.spyOn(useKeypressModule, 'useKeypress').mockImplementation(
(handler: KeypressHandler, options?: UseKeypressMockOptions) => {
@@ -52,6 +53,10 @@ describe('useSelectionList', () => {
mockOnHighlight.mockClear();
});
afterEach(() => {
vi.useRealTimers();
});
const pressKey = (
name: string,
sequence: string = name,
@@ -530,14 +535,6 @@ describe('useSelectionList', () => {
});
describe('Numeric Quick Selection (showNumbers=true)', () => {
beforeEach(() => {
vi.useFakeTimers();
});
afterEach(() => {
vi.useRealTimers();
});
const shortList = items;
const longList: Array<SelectionListItem<string>> = Array.from(
{ length: 15 },