mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-06 11:21:15 -07:00
refactor(cli): integrate real config loading into async test utils (#23040)
This commit is contained in:
committed by
GitHub
parent
7de0616229
commit
23264ced9a
@@ -49,10 +49,10 @@ class MockStdin extends EventEmitter {
|
||||
}
|
||||
|
||||
// Helper function to setup keypress test with standard configuration
|
||||
const setupKeypressTest = () => {
|
||||
const setupKeypressTest = async () => {
|
||||
const keyHandler = vi.fn();
|
||||
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() => useKeypressContext());
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
return { result, keyHandler };
|
||||
@@ -85,7 +85,7 @@ describe('KeypressContext', () => {
|
||||
sequence: '\x1b[57414u',
|
||||
},
|
||||
])('should recognize $name in kitty protocol', async ({ sequence }) => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => stdin.write(sequence));
|
||||
|
||||
@@ -100,7 +100,7 @@ describe('KeypressContext', () => {
|
||||
});
|
||||
|
||||
it('should handle backslash return', async () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => stdin.write('\\\r'));
|
||||
|
||||
@@ -133,7 +133,7 @@ describe('KeypressContext', () => {
|
||||
])(
|
||||
'should handle numpad enter with $modifier modifier',
|
||||
async ({ sequence, expected }) => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => stdin.write(sequence));
|
||||
|
||||
@@ -147,7 +147,7 @@ describe('KeypressContext', () => {
|
||||
);
|
||||
|
||||
it('should recognize \n (LF) as ctrl+j', async () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => stdin.write('\n'));
|
||||
|
||||
@@ -162,7 +162,7 @@ describe('KeypressContext', () => {
|
||||
});
|
||||
|
||||
it('should recognize \\x1b\\n as Alt+Enter (return with meta)', async () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => stdin.write('\x1b\n'));
|
||||
|
||||
@@ -190,7 +190,7 @@ describe('KeypressContext', () => {
|
||||
afterEach(() => kittySpy.mockRestore());
|
||||
|
||||
it('should buffer return key pressed quickly after another key', async () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => stdin.write('a'));
|
||||
expect(keyHandler).toHaveBeenLastCalledWith(
|
||||
@@ -219,7 +219,7 @@ describe('KeypressContext', () => {
|
||||
});
|
||||
|
||||
it('should NOT buffer return key if delay is long enough', async () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => stdin.write('a'));
|
||||
|
||||
@@ -241,7 +241,7 @@ describe('KeypressContext', () => {
|
||||
|
||||
describe('Escape key handling', () => {
|
||||
it('should recognize escape key (keycode 27) in kitty protocol', async () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
// Send kitty protocol sequence for escape: ESC[27u
|
||||
act(() => {
|
||||
@@ -261,7 +261,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should handle double Escape', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
act(() => {
|
||||
@@ -295,7 +297,9 @@ describe('KeypressContext', () => {
|
||||
it('should handle lone Escape key (keycode 27) with timeout when kitty protocol is enabled', async () => {
|
||||
// Use real timers for this test to avoid issues with stream/buffer timing
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
// Send just ESC
|
||||
@@ -369,7 +373,7 @@ describe('KeypressContext', () => {
|
||||
])(
|
||||
'should recognize $name in kitty protocol',
|
||||
async ({ inputSequence, expected }) => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => {
|
||||
stdin.write(inputSequence);
|
||||
@@ -418,7 +422,9 @@ describe('KeypressContext', () => {
|
||||
])('should $name', async ({ pastedText, writeSequence }) => {
|
||||
const keyHandler = vi.fn();
|
||||
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -438,7 +444,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should parse valid OSC 52 response', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -459,7 +467,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should handle split OSC 52 response', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -485,7 +495,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should handle OSC 52 response terminated by ESC \\', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -506,7 +518,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should ignore unknown OSC sequences', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -523,7 +537,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should ignore invalid OSC 52 format', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -555,11 +571,14 @@ describe('KeypressContext', () => {
|
||||
it('should not log keystrokes when debugKeystrokeLogging is false', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext(), {
|
||||
settings: createMockSettings({
|
||||
general: { debugKeystrokeLogging: false },
|
||||
}),
|
||||
});
|
||||
const { result } = await renderHookWithProviders(
|
||||
() => useKeypressContext(),
|
||||
{
|
||||
settings: createMockSettings({
|
||||
general: { debugKeystrokeLogging: false },
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -577,11 +596,14 @@ describe('KeypressContext', () => {
|
||||
it('should log kitty buffer accumulation when debugKeystrokeLogging is true', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext(), {
|
||||
settings: createMockSettings({
|
||||
general: { debugKeystrokeLogging: true },
|
||||
}),
|
||||
});
|
||||
const { result } = await renderHookWithProviders(
|
||||
() => useKeypressContext(),
|
||||
{
|
||||
settings: createMockSettings({
|
||||
general: { debugKeystrokeLogging: true },
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -596,11 +618,14 @@ describe('KeypressContext', () => {
|
||||
it('should show char codes when debugKeystrokeLogging is true even without debug mode', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext(), {
|
||||
settings: createMockSettings({
|
||||
general: { debugKeystrokeLogging: true },
|
||||
}),
|
||||
});
|
||||
const { result } = await renderHookWithProviders(
|
||||
() => useKeypressContext(),
|
||||
{
|
||||
settings: createMockSettings({
|
||||
general: { debugKeystrokeLogging: true },
|
||||
}),
|
||||
},
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -743,9 +768,11 @@ describe('KeypressContext', () => {
|
||||
},
|
||||
])(
|
||||
'should recognize sequence "$sequence" as $expected.name',
|
||||
({ sequence, expected }) => {
|
||||
async ({ sequence, expected }) => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
act(() => stdin.write(sequence));
|
||||
@@ -835,8 +862,8 @@ describe('KeypressContext', () => {
|
||||
},
|
||||
])(
|
||||
'should recognize numpad sequence "$sequence" as $expected.name',
|
||||
({ sequence, expected }) => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
async ({ sequence, expected }) => {
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
act(() => stdin.write(sequence));
|
||||
expect(keyHandler).toHaveBeenCalledWith(
|
||||
expect.objectContaining(expected),
|
||||
@@ -847,7 +874,7 @@ describe('KeypressContext', () => {
|
||||
|
||||
describe('Double-tap and batching', () => {
|
||||
it('should emit two delete events for double-tap CSI[3~', async () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => stdin.write(`\x1b[3~`));
|
||||
act(() => stdin.write(`\x1b[3~`));
|
||||
@@ -875,7 +902,7 @@ describe('KeypressContext', () => {
|
||||
});
|
||||
|
||||
it('should parse two concatenated tilde-coded sequences in one chunk', async () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => stdin.write(`\x1b[3~\x1b[5~`));
|
||||
|
||||
@@ -978,9 +1005,17 @@ describe('KeypressContext', () => {
|
||||
),
|
||||
)(
|
||||
'should handle Alt+$key in $terminal',
|
||||
({ chunk, expected }: { chunk: string; expected: Partial<Key> }) => {
|
||||
async ({
|
||||
chunk,
|
||||
expected,
|
||||
}: {
|
||||
chunk: string;
|
||||
expected: Partial<Key>;
|
||||
}) => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
act(() => stdin.write(chunk));
|
||||
@@ -993,8 +1028,8 @@ describe('KeypressContext', () => {
|
||||
});
|
||||
|
||||
describe('Backslash key handling', () => {
|
||||
it('should treat backslash as a regular keystroke', () => {
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
it('should treat backslash as a regular keystroke', async () => {
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => stdin.write('\\'));
|
||||
|
||||
@@ -1017,7 +1052,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should timeout and flush incomplete kitty sequences after 50ms', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1052,7 +1089,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should immediately flush non-kitty CSI sequences', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1074,7 +1113,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should parse valid kitty sequences immediately when complete', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1092,7 +1133,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should handle batched kitty sequences correctly', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1119,7 +1162,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should handle mixed valid and invalid sequences', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1147,7 +1192,9 @@ describe('KeypressContext', () => {
|
||||
'should handle sequences arriving character by character with %s ms delay',
|
||||
async (delay) => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1171,7 +1218,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should reset timeout when new input arrives', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1206,7 +1255,9 @@ describe('KeypressContext', () => {
|
||||
describe('SGR Mouse Handling', () => {
|
||||
it('should ignore SGR mouse sequences', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1224,7 +1275,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should handle mixed SGR mouse and key sequences', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1250,7 +1303,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should ignore X11 mouse sequences', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1266,7 +1321,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should not flush slow SGR mouse sequences as garbage', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1286,7 +1343,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should ignore specific SGR mouse sequence sandwiched between keystrokes', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
@@ -1317,7 +1376,9 @@ describe('KeypressContext', () => {
|
||||
{ name: 'another mouse', sequence: '\u001b[<0;29;19m' },
|
||||
])('should ignore $name sequence', async ({ sequence }) => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
for (const char of sequence) {
|
||||
@@ -1342,7 +1403,9 @@ describe('KeypressContext', () => {
|
||||
|
||||
it('should handle F12', async () => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
act(() => {
|
||||
@@ -1371,7 +1434,9 @@ describe('KeypressContext', () => {
|
||||
'A你B好C', // Mixed characters
|
||||
])('should correctly handle string "%s"', async (inputString) => {
|
||||
const keyHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useKeypressContext());
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useKeypressContext(),
|
||||
);
|
||||
act(() => result.current.subscribe(keyHandler));
|
||||
|
||||
act(() => stdin.write(inputString));
|
||||
@@ -1424,7 +1489,7 @@ describe('KeypressContext', () => {
|
||||
if (lang) vi.stubEnv('LANG', lang);
|
||||
if (lcAll) vi.stubEnv('LC_ALL', lcAll);
|
||||
|
||||
const { keyHandler } = setupKeypressTest();
|
||||
const { keyHandler } = await setupKeypressTest();
|
||||
|
||||
act(() => stdin.write(char));
|
||||
|
||||
|
||||
@@ -62,9 +62,9 @@ describe('MouseContext', () => {
|
||||
vi.restoreAllMocks();
|
||||
});
|
||||
|
||||
it('should subscribe and unsubscribe a handler', () => {
|
||||
it('should subscribe and unsubscribe a handler', async () => {
|
||||
const handler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useMouseContext(), {
|
||||
const { result } = await renderHookWithProviders(() => useMouseContext(), {
|
||||
mouseEventsEnabled: true,
|
||||
});
|
||||
|
||||
@@ -89,11 +89,14 @@ describe('MouseContext', () => {
|
||||
expect(handler).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should not call handler if not active', () => {
|
||||
it('should not call handler if not active', async () => {
|
||||
const handler = vi.fn();
|
||||
renderHookWithProviders(() => useMouse(handler, { isActive: false }), {
|
||||
mouseEventsEnabled: true,
|
||||
});
|
||||
await renderHookWithProviders(
|
||||
() => useMouse(handler, { isActive: false }),
|
||||
{
|
||||
mouseEventsEnabled: true,
|
||||
},
|
||||
);
|
||||
|
||||
act(() => {
|
||||
stdin.write('\x1b[<0;10;20M');
|
||||
@@ -102,8 +105,8 @@ describe('MouseContext', () => {
|
||||
expect(handler).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit SelectionWarning when move event is unhandled and has coordinates', () => {
|
||||
renderHookWithProviders(() => useMouseContext(), {
|
||||
it('should emit SelectionWarning when move event is unhandled and has coordinates', async () => {
|
||||
await renderHookWithProviders(() => useMouseContext(), {
|
||||
mouseEventsEnabled: true,
|
||||
});
|
||||
|
||||
@@ -115,9 +118,9 @@ describe('MouseContext', () => {
|
||||
expect(appEvents.emit).toHaveBeenCalledWith(AppEvent.SelectionWarning);
|
||||
});
|
||||
|
||||
it('should not emit SelectionWarning when move event is handled', () => {
|
||||
it('should not emit SelectionWarning when move event is handled', async () => {
|
||||
const handler = vi.fn().mockReturnValue(true);
|
||||
const { result } = renderHookWithProviders(() => useMouseContext(), {
|
||||
const { result } = await renderHookWithProviders(() => useMouseContext(), {
|
||||
mouseEventsEnabled: true,
|
||||
});
|
||||
|
||||
@@ -217,11 +220,14 @@ describe('MouseContext', () => {
|
||||
}, // Shift + scroll up
|
||||
])(
|
||||
'should recognize sequence "$sequence" as $expected.name',
|
||||
({ sequence, expected }) => {
|
||||
async ({ sequence, expected }) => {
|
||||
const mouseHandler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useMouseContext(), {
|
||||
mouseEventsEnabled: true,
|
||||
});
|
||||
const { result } = await renderHookWithProviders(
|
||||
() => useMouseContext(),
|
||||
{
|
||||
mouseEventsEnabled: true,
|
||||
},
|
||||
);
|
||||
act(() => result.current.subscribe(mouseHandler));
|
||||
|
||||
act(() => stdin.write(sequence));
|
||||
@@ -233,9 +239,9 @@ describe('MouseContext', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should emit a double-click event when two left-presses occur quickly at the same position', () => {
|
||||
it('should emit a double-click event when two left-presses occur quickly at the same position', async () => {
|
||||
const handler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useMouseContext(), {
|
||||
const { result } = await renderHookWithProviders(() => useMouseContext(), {
|
||||
mouseEventsEnabled: true,
|
||||
});
|
||||
|
||||
@@ -265,9 +271,9 @@ describe('MouseContext', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should NOT emit a double-click event if clicks are too far apart', () => {
|
||||
it('should NOT emit a double-click event if clicks are too far apart', async () => {
|
||||
const handler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useMouseContext(), {
|
||||
const { result } = await renderHookWithProviders(() => useMouseContext(), {
|
||||
mouseEventsEnabled: true,
|
||||
});
|
||||
|
||||
@@ -294,7 +300,7 @@ describe('MouseContext', () => {
|
||||
it('should NOT emit a double-click event if too much time passes', async () => {
|
||||
vi.useFakeTimers();
|
||||
const handler = vi.fn();
|
||||
const { result } = renderHookWithProviders(() => useMouseContext(), {
|
||||
const { result } = await renderHookWithProviders(() => useMouseContext(), {
|
||||
mouseEventsEnabled: true,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user