mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-15 12:30:32 -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
@@ -30,10 +30,10 @@ describe('useReverseSearchCompletion', () => {
|
||||
|
||||
describe('Core Hook Behavior', () => {
|
||||
describe('State Management', () => {
|
||||
it('should initialize with default state', () => {
|
||||
it('should initialize with default state', async () => {
|
||||
const mockShellHistory = ['echo hello'];
|
||||
|
||||
const { result } = renderHookWithProviders(() =>
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useReverseSearchCompletion(
|
||||
useTextBufferForTest(''),
|
||||
mockShellHistory,
|
||||
@@ -48,9 +48,9 @@ describe('useReverseSearchCompletion', () => {
|
||||
expect(result.current.isLoadingSuggestions).toBe(false);
|
||||
});
|
||||
|
||||
it('should reset state when reverseSearchActive becomes false', () => {
|
||||
it('should reset state when reverseSearchActive becomes false', async () => {
|
||||
const mockShellHistory = ['echo hello'];
|
||||
const { result, rerender } = renderHookWithProviders(
|
||||
const { result, rerender } = await renderHookWithProviders(
|
||||
({ text, active }) => {
|
||||
const textBuffer = useTextBufferForTest(text);
|
||||
return useReverseSearchCompletion(
|
||||
@@ -72,10 +72,10 @@ describe('useReverseSearchCompletion', () => {
|
||||
});
|
||||
|
||||
describe('Navigation', () => {
|
||||
it('should handle navigateUp with no suggestions', () => {
|
||||
it('should handle navigateUp with no suggestions', async () => {
|
||||
const mockShellHistory = ['echo hello'];
|
||||
|
||||
const { result } = renderHookWithProviders(() =>
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useReverseSearchCompletion(
|
||||
useTextBufferForTest('grep'),
|
||||
mockShellHistory,
|
||||
@@ -90,9 +90,9 @@ describe('useReverseSearchCompletion', () => {
|
||||
expect(result.current.activeSuggestionIndex).toBe(-1);
|
||||
});
|
||||
|
||||
it('should handle navigateDown with no suggestions', () => {
|
||||
it('should handle navigateDown with no suggestions', async () => {
|
||||
const mockShellHistory = ['echo hello'];
|
||||
const { result } = renderHookWithProviders(() =>
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useReverseSearchCompletion(
|
||||
useTextBufferForTest('grep'),
|
||||
mockShellHistory,
|
||||
@@ -107,7 +107,7 @@ describe('useReverseSearchCompletion', () => {
|
||||
expect(result.current.activeSuggestionIndex).toBe(-1);
|
||||
});
|
||||
|
||||
it('should navigate up through suggestions with wrap-around', () => {
|
||||
it('should navigate up through suggestions with wrap-around', async () => {
|
||||
const mockShellHistory = [
|
||||
'ls -l',
|
||||
'ls -la',
|
||||
@@ -117,7 +117,7 @@ describe('useReverseSearchCompletion', () => {
|
||||
'echo Hi',
|
||||
];
|
||||
|
||||
const { result } = renderHookWithProviders(() =>
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useReverseSearchCompletion(
|
||||
useTextBufferForTest('echo'),
|
||||
mockShellHistory,
|
||||
@@ -135,7 +135,7 @@ describe('useReverseSearchCompletion', () => {
|
||||
expect(result.current.activeSuggestionIndex).toBe(1);
|
||||
});
|
||||
|
||||
it('should navigate down through suggestions with wrap-around', () => {
|
||||
it('should navigate down through suggestions with wrap-around', async () => {
|
||||
const mockShellHistory = [
|
||||
'ls -l',
|
||||
'ls -la',
|
||||
@@ -144,7 +144,7 @@ describe('useReverseSearchCompletion', () => {
|
||||
'echo "Hello, World!"',
|
||||
'echo Hi',
|
||||
];
|
||||
const { result } = renderHookWithProviders(() =>
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useReverseSearchCompletion(
|
||||
useTextBufferForTest('ls'),
|
||||
mockShellHistory,
|
||||
@@ -162,7 +162,7 @@ describe('useReverseSearchCompletion', () => {
|
||||
expect(result.current.activeSuggestionIndex).toBe(1);
|
||||
});
|
||||
|
||||
it('should handle navigation with multiple suggestions', () => {
|
||||
it('should handle navigation with multiple suggestions', async () => {
|
||||
const mockShellHistory = [
|
||||
'ls -l',
|
||||
'ls -la',
|
||||
@@ -172,7 +172,7 @@ describe('useReverseSearchCompletion', () => {
|
||||
'echo "Hi all"',
|
||||
];
|
||||
|
||||
const { result } = renderHookWithProviders(() =>
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useReverseSearchCompletion(
|
||||
useTextBufferForTest('l'),
|
||||
mockShellHistory,
|
||||
@@ -209,13 +209,13 @@ describe('useReverseSearchCompletion', () => {
|
||||
expect(result.current.activeSuggestionIndex).toBe(4);
|
||||
});
|
||||
|
||||
it('should handle navigation with large suggestion lists and scrolling', () => {
|
||||
it('should handle navigation with large suggestion lists and scrolling', async () => {
|
||||
const largeMockCommands = Array.from(
|
||||
{ length: 15 },
|
||||
(_, i) => `echo ${i}`,
|
||||
);
|
||||
|
||||
const { result } = renderHookWithProviders(() =>
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useReverseSearchCompletion(
|
||||
useTextBufferForTest('echo'),
|
||||
largeMockCommands,
|
||||
@@ -239,9 +239,9 @@ describe('useReverseSearchCompletion', () => {
|
||||
});
|
||||
|
||||
describe('Filtering', () => {
|
||||
it('filters history by buffer.text and sets showSuggestions', () => {
|
||||
it('filters history by buffer.text and sets showSuggestions', async () => {
|
||||
const history = ['foo', 'barfoo', 'baz'];
|
||||
const { result } = renderHookWithProviders(() =>
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useReverseSearchCompletion(useTextBufferForTest('foo'), history, true),
|
||||
);
|
||||
|
||||
@@ -253,9 +253,9 @@ describe('useReverseSearchCompletion', () => {
|
||||
expect(result.current.showSuggestions).toBe(true);
|
||||
});
|
||||
|
||||
it('hides suggestions when there are no matches', () => {
|
||||
it('hides suggestions when there are no matches', async () => {
|
||||
const history = ['alpha', 'beta'];
|
||||
const { result } = renderHookWithProviders(() =>
|
||||
const { result } = await renderHookWithProviders(() =>
|
||||
useReverseSearchCompletion(useTextBufferForTest('γ'), history, true),
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user