mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-16 09:01:17 -07:00
Fix tests to wrap all calls changing the UI with act. (#12268)
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { act } from 'react';
|
||||
import { render } from 'ink-testing-library';
|
||||
import { render } from '../../test-utils/render.js';
|
||||
import { useModelCommand } from './useModelCommand.js';
|
||||
|
||||
describe('useModelCommand', () => {
|
||||
@@ -18,22 +18,24 @@ describe('useModelCommand', () => {
|
||||
}
|
||||
|
||||
it('should initialize with the model dialog closed', () => {
|
||||
render(<TestComponent />);
|
||||
const { unmount } = render(<TestComponent />);
|
||||
expect(result.isModelDialogOpen).toBe(false);
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should open the model dialog when openModelDialog is called', () => {
|
||||
render(<TestComponent />);
|
||||
const { unmount } = render(<TestComponent />);
|
||||
|
||||
act(() => {
|
||||
result.openModelDialog();
|
||||
});
|
||||
|
||||
expect(result.isModelDialogOpen).toBe(true);
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should close the model dialog when closeModelDialog is called', () => {
|
||||
render(<TestComponent />);
|
||||
const { unmount } = render(<TestComponent />);
|
||||
|
||||
// Open it first
|
||||
act(() => {
|
||||
@@ -46,5 +48,6 @@ describe('useModelCommand', () => {
|
||||
result.closeModelDialog();
|
||||
});
|
||||
expect(result.isModelDialogOpen).toBe(false);
|
||||
unmount();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user