2025-09-23 12:50:09 -04:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-12-17 09:43:21 -08:00
|
|
|
import { describe, it, expect, beforeEach, vi } from 'vitest';
|
2025-09-23 12:50:09 -04:00
|
|
|
import { modelCommand } from './modelCommand.js';
|
|
|
|
|
import { type CommandContext } from './types.js';
|
|
|
|
|
import { createMockCommandContext } from '../../test-utils/mockCommandContext.js';
|
2025-12-17 09:43:21 -08:00
|
|
|
import type { Config } from '@google/gemini-cli-core';
|
2025-09-23 12:50:09 -04:00
|
|
|
|
|
|
|
|
describe('modelCommand', () => {
|
|
|
|
|
let mockContext: CommandContext;
|
|
|
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
|
mockContext = createMockCommandContext();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return a dialog action to open the model dialog', async () => {
|
|
|
|
|
if (!modelCommand.action) {
|
|
|
|
|
throw new Error('The model command must have an action.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const result = await modelCommand.action(mockContext, '');
|
|
|
|
|
|
|
|
|
|
expect(result).toEqual({
|
|
|
|
|
type: 'dialog',
|
|
|
|
|
dialog: 'model',
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
2025-12-17 09:43:21 -08:00
|
|
|
it('should call refreshUserQuota if config is available', async () => {
|
|
|
|
|
if (!modelCommand.action) {
|
|
|
|
|
throw new Error('The model command must have an action.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mockRefreshUserQuota = vi.fn();
|
|
|
|
|
mockContext.services.config = {
|
|
|
|
|
refreshUserQuota: mockRefreshUserQuota,
|
|
|
|
|
} as unknown as Config;
|
|
|
|
|
|
|
|
|
|
await modelCommand.action(mockContext, '');
|
|
|
|
|
|
|
|
|
|
expect(mockRefreshUserQuota).toHaveBeenCalled();
|
|
|
|
|
});
|
|
|
|
|
|
2025-09-23 12:50:09 -04:00
|
|
|
it('should have the correct name and description', () => {
|
|
|
|
|
expect(modelCommand.name).toBe('model');
|
|
|
|
|
expect(modelCommand.description).toBe(
|
|
|
|
|
'Opens a dialog to configure the model',
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
});
|