Path: blob/main/src/vs/platform/agentHost/test/node/gitDiffContent.test.ts
13399 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import assert from 'assert';6import { ensureNoDisposablesAreLeakedInTestSuite } from '../../../../base/test/common/utils.js';7import { buildGitBlobUri, parseGitBlobUri } from '../../node/gitDiffContent.js';89suite('gitDiffContent', () => {10ensureNoDisposablesAreLeakedInTestSuite();1112test('round-trips simple inputs', () => {13const sessionUri = 'copilot:/abc-123';14const sha = 'deadbeef0123456789abcdef0123456789abcdef';15const path = 'src/foo/bar.ts';16const built = buildGitBlobUri(sessionUri, sha, path);17const parsed = parseGitBlobUri(built);18assert.deepStrictEqual(parsed, { sessionUri, sha, repoRelativePath: path });19});2021test('round-trips paths with spaces, unicode and slashes', () => {22const sessionUri = 'copilot:/sess/with space?q=1';23const sha = '1234567890abcdef1234567890abcdef12345678';24const path = 'a folder/файл.txt';25const parsed = parseGitBlobUri(buildGitBlobUri(sessionUri, sha, path));26assert.deepStrictEqual(parsed, { sessionUri, sha, repoRelativePath: path });27});2829test('returns undefined for non git-blob URIs', () => {30assert.strictEqual(parseGitBlobUri('file:///foo/bar.ts'), undefined);31assert.strictEqual(parseGitBlobUri('session-db://abc/def/before/x'), undefined);32assert.strictEqual(parseGitBlobUri('not a uri at all'), undefined);33});34});353637