mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-30 15:04:16 -07:00
fix(config): Enable type checking for config tests (#11436)
This commit is contained in:
@@ -46,7 +46,6 @@ import {
|
||||
afterEach,
|
||||
type Mocked,
|
||||
type Mock,
|
||||
fail,
|
||||
} from 'vitest';
|
||||
import * as fs from 'node:fs'; // fs will be mocked separately
|
||||
import stripJsonComments from 'strip-json-comments'; // Will be mocked separately
|
||||
@@ -1266,7 +1265,7 @@ describe('Settings Loading and Merging', () => {
|
||||
|
||||
try {
|
||||
loadSettings(MOCK_WORKSPACE_DIR);
|
||||
fail('loadSettings should have thrown a FatalConfigError');
|
||||
throw new Error('loadSettings should have thrown a FatalConfigError');
|
||||
} catch (e) {
|
||||
expect(e).toBeInstanceOf(FatalConfigError);
|
||||
const error = e as FatalConfigError;
|
||||
@@ -1336,9 +1335,10 @@ describe('Settings Loading and Merging', () => {
|
||||
expect((settings.workspace.settings as TestSettings)['endpoint']).toBe(
|
||||
'workspace_endpoint_from_env/api',
|
||||
);
|
||||
expect(
|
||||
(settings.workspace.settings as TestSettings)['nested']['value'],
|
||||
).toBe('workspace_endpoint_from_env');
|
||||
const nested = (settings.workspace.settings as TestSettings)[
|
||||
'nested'
|
||||
] as Record<string, unknown>;
|
||||
expect(nested['value']).toBe('workspace_endpoint_from_env');
|
||||
expect((settings.merged as TestSettings)['endpoint']).toBe(
|
||||
'workspace_endpoint_from_env/api',
|
||||
);
|
||||
@@ -1586,21 +1586,14 @@ describe('Settings Loading and Merging', () => {
|
||||
(settings.user.settings as TestSettings)['undefinedVal'],
|
||||
).toBeUndefined();
|
||||
|
||||
expect(
|
||||
(settings.user.settings as TestSettings)['nestedObj']['nestedNull'],
|
||||
).toBeNull();
|
||||
expect(
|
||||
(settings.user.settings as TestSettings)['nestedObj']['nestedBool'],
|
||||
).toBe(true);
|
||||
expect(
|
||||
(settings.user.settings as TestSettings)['nestedObj']['nestedNum'],
|
||||
).toBe(0);
|
||||
expect(
|
||||
(settings.user.settings as TestSettings)['nestedObj']['nestedString'],
|
||||
).toBe('literal');
|
||||
expect(
|
||||
(settings.user.settings as TestSettings)['nestedObj']['anotherEnv'],
|
||||
).toBe('env_string_nested_value');
|
||||
const nestedObj = (settings.user.settings as TestSettings)[
|
||||
'nestedObj'
|
||||
] as Record<string, unknown>;
|
||||
expect(nestedObj['nestedNull']).toBeNull();
|
||||
expect(nestedObj['nestedBool']).toBe(true);
|
||||
expect(nestedObj['nestedNum']).toBe(0);
|
||||
expect(nestedObj['nestedString']).toBe('literal');
|
||||
expect(nestedObj['anotherEnv']).toBe('env_string_nested_value');
|
||||
|
||||
delete process.env['MY_ENV_STRING'];
|
||||
delete process.env['MY_ENV_STRING_NESTED'];
|
||||
@@ -2136,14 +2129,14 @@ describe('Settings Loading and Merging', () => {
|
||||
vimMode: false,
|
||||
},
|
||||
model: {
|
||||
maxSessionTurns: 0,
|
||||
maxSessionTurns: -1,
|
||||
},
|
||||
context: {
|
||||
includeDirectories: [],
|
||||
},
|
||||
security: {
|
||||
folderTrust: {
|
||||
enabled: null,
|
||||
enabled: undefined,
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -2152,9 +2145,13 @@ describe('Settings Loading and Merging', () => {
|
||||
|
||||
expect(v1Settings).toEqual({
|
||||
vimMode: false,
|
||||
maxSessionTurns: 0,
|
||||
maxSessionTurns: -1,
|
||||
includeDirectories: [],
|
||||
folderTrust: null,
|
||||
security: {
|
||||
folderTrust: {
|
||||
enabled: undefined,
|
||||
},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -2342,9 +2339,9 @@ describe('Settings Loading and Merging', () => {
|
||||
});
|
||||
|
||||
describe('migrateDeprecatedSettings', () => {
|
||||
let mockFsExistsSync: Mocked<typeof fs.existsSync>;
|
||||
let mockFsReadFileSync: Mocked<typeof fs.readFileSync>;
|
||||
let mockDisableExtension: Mocked<typeof disableExtension>;
|
||||
let mockFsExistsSync: Mock;
|
||||
let mockFsReadFileSync: Mock;
|
||||
let mockDisableExtension: Mock;
|
||||
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks();
|
||||
|
||||
Reference in New Issue
Block a user