mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-26 13:04:49 -07:00
test(cli): refactor tests for async render utilities (#23252)
This commit is contained in:
committed by
GitHub
parent
86a3a913b5
commit
6c78eb7a39
@@ -15,14 +15,14 @@ describe('useInputHistoryStore', () => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('should initialize with empty input history', () => {
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
it('should initialize with empty input history', async () => {
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
expect(result.current.inputHistory).toEqual([]);
|
||||
});
|
||||
|
||||
it('should add input to history', () => {
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
it('should add input to history', async () => {
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
act(() => {
|
||||
result.current.addInput('test message 1');
|
||||
@@ -40,8 +40,8 @@ describe('useInputHistoryStore', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('should not add empty or whitespace-only inputs', () => {
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
it('should not add empty or whitespace-only inputs', async () => {
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
act(() => {
|
||||
result.current.addInput('');
|
||||
@@ -56,8 +56,8 @@ describe('useInputHistoryStore', () => {
|
||||
expect(result.current.inputHistory).toEqual([]);
|
||||
});
|
||||
|
||||
it('should deduplicate consecutive identical messages', () => {
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
it('should deduplicate consecutive identical messages', async () => {
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
act(() => {
|
||||
result.current.addInput('test message');
|
||||
@@ -91,7 +91,7 @@ describe('useInputHistoryStore', () => {
|
||||
.mockResolvedValue(['newest', 'middle', 'oldest']),
|
||||
};
|
||||
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
await act(async () => {
|
||||
await result.current.initializeFromLogger(mockLogger);
|
||||
@@ -113,7 +113,7 @@ describe('useInputHistoryStore', () => {
|
||||
.spyOn(debugLogger, 'warn')
|
||||
.mockImplementation(() => {});
|
||||
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
await act(async () => {
|
||||
await result.current.initializeFromLogger(mockLogger);
|
||||
@@ -135,7 +135,7 @@ describe('useInputHistoryStore', () => {
|
||||
.mockResolvedValue(['message1', 'message2']),
|
||||
};
|
||||
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
// Call initializeFromLogger twice
|
||||
await act(async () => {
|
||||
@@ -152,7 +152,7 @@ describe('useInputHistoryStore', () => {
|
||||
});
|
||||
|
||||
it('should handle null logger gracefully', async () => {
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
await act(async () => {
|
||||
await result.current.initializeFromLogger(null);
|
||||
@@ -161,8 +161,8 @@ describe('useInputHistoryStore', () => {
|
||||
expect(result.current.inputHistory).toEqual([]);
|
||||
});
|
||||
|
||||
it('should trim input before adding to history', () => {
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
it('should trim input before adding to history', async () => {
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
act(() => {
|
||||
result.current.addInput(' test message ');
|
||||
@@ -185,7 +185,7 @@ describe('useInputHistoryStore', () => {
|
||||
]), // newest first with duplicates
|
||||
};
|
||||
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
await act(async () => {
|
||||
await result.current.initializeFromLogger(mockLogger);
|
||||
@@ -204,7 +204,7 @@ describe('useInputHistoryStore', () => {
|
||||
getPreviousUserMessages: vi.fn().mockResolvedValue(['old2', 'old1']), // newest first
|
||||
};
|
||||
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
// Initialize with past session
|
||||
await act(async () => {
|
||||
@@ -233,7 +233,7 @@ describe('useInputHistoryStore', () => {
|
||||
.mockResolvedValue(['message2', 'message1', 'message2']), // newest first with non-consecutive duplicate
|
||||
};
|
||||
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
await act(async () => {
|
||||
await result.current.initializeFromLogger(mockLogger);
|
||||
@@ -247,8 +247,8 @@ describe('useInputHistoryStore', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('should handle complex deduplication with current session', () => {
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
it('should handle complex deduplication with current session', async () => {
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
// Add multiple messages with duplicates
|
||||
act(() => {
|
||||
@@ -278,7 +278,7 @@ describe('useInputHistoryStore', () => {
|
||||
.mockResolvedValue(['newest', 'middle', 'oldest']), // newest first
|
||||
};
|
||||
|
||||
const { result } = renderHook(() => useInputHistoryStore());
|
||||
const { result } = await renderHook(() => useInputHistoryStore());
|
||||
|
||||
await act(async () => {
|
||||
await result.current.initializeFromLogger(mockLogger);
|
||||
|
||||
Reference in New Issue
Block a user