mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-22 20:14:58 -07:00
First batch of fixing tests to use best practices. (#11964)
This commit is contained in:
50
packages/cli/src/ui/hooks/useModelCommand.test.tsx
Normal file
50
packages/cli/src/ui/hooks/useModelCommand.test.tsx
Normal file
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { describe, it, expect } from 'vitest';
|
||||
import { act } from 'react';
|
||||
import { render } from 'ink-testing-library';
|
||||
import { useModelCommand } from './useModelCommand.js';
|
||||
|
||||
describe('useModelCommand', () => {
|
||||
let result: ReturnType<typeof useModelCommand>;
|
||||
|
||||
function TestComponent() {
|
||||
result = useModelCommand();
|
||||
return null;
|
||||
}
|
||||
|
||||
it('should initialize with the model dialog closed', () => {
|
||||
render(<TestComponent />);
|
||||
expect(result.isModelDialogOpen).toBe(false);
|
||||
});
|
||||
|
||||
it('should open the model dialog when openModelDialog is called', () => {
|
||||
render(<TestComponent />);
|
||||
|
||||
act(() => {
|
||||
result.openModelDialog();
|
||||
});
|
||||
|
||||
expect(result.isModelDialogOpen).toBe(true);
|
||||
});
|
||||
|
||||
it('should close the model dialog when closeModelDialog is called', () => {
|
||||
render(<TestComponent />);
|
||||
|
||||
// Open it first
|
||||
act(() => {
|
||||
result.openModelDialog();
|
||||
});
|
||||
expect(result.isModelDialogOpen).toBe(true);
|
||||
|
||||
// Then close it
|
||||
act(() => {
|
||||
result.closeModelDialog();
|
||||
});
|
||||
expect(result.isModelDialogOpen).toBe(false);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user