mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-11 22:51:00 -07:00
36 lines
971 B
TypeScript
36 lines
971 B
TypeScript
/**
|
|
* @license
|
|
* Copyright 2025 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
import * as os from 'node:os';
|
|
import * as path from 'node:path';
|
|
import { resolvePath } from './resolvePath.js';
|
|
|
|
vi.mock('node:os', () => ({
|
|
homedir: vi.fn(),
|
|
}));
|
|
|
|
describe('resolvePath', () => {
|
|
beforeEach(() => {
|
|
vi.mocked(os.homedir).mockReturnValue('/home/user');
|
|
});
|
|
|
|
it.each([
|
|
['', ''],
|
|
['/foo/bar', path.normalize('/foo/bar')],
|
|
['~/foo', path.join('/home/user', 'foo')],
|
|
['~', path.normalize('/home/user')],
|
|
['%userprofile%/foo', path.join('/home/user', 'foo')],
|
|
['%USERPROFILE%/foo', path.join('/home/user', 'foo')],
|
|
])('resolvePath(%s) should return %s', (input, expected) => {
|
|
expect(resolvePath(input)).toBe(expected);
|
|
});
|
|
|
|
it('should handle path normalization', () => {
|
|
expect(resolvePath('/foo//bar/../baz')).toBe(path.normalize('/foo/baz'));
|
|
});
|
|
});
|