Fix tests to use URI.file() for platform-independent paths

Co-authored-by: mjbvz <12821956+mjbvz@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-03-06 18:47:40 +00:00
parent d8bad4f1d4
commit 88a4ff6324

View File

@@ -308,25 +308,28 @@ suite('MarkdownRenderer', () => {
});
test('Should use decoded file path as title for file:// links', () => {
const md = new MarkdownString(`[log](file:///home/user/project/lib.d.ts)`, {});
const fileUri = URI.file('/home/user/project/lib.d.ts');
const md = new MarkdownString(`[log](${fileUri.toString()})`, {});
const result = store.add(renderMarkdown(md)).element;
const anchor = result.querySelector('a')!;
assert.ok(anchor);
assert.strictEqual(anchor.title, '/home/user/project/lib.d.ts');
assert.strictEqual(anchor.title, fileUri.fsPath);
});
test('Should include fragment in title for file:// links with line numbers', () => {
const md = new MarkdownString(`[log](file:///home/user/project/lib.d.ts#L42)`, {});
const fileUri = URI.file('/home/user/project/lib.d.ts');
const md = new MarkdownString(`[log](${fileUri.toString()}#L42)`, {});
const result = store.add(renderMarkdown(md)).element;
const anchor = result.querySelector('a')!;
assert.ok(anchor);
assert.strictEqual(anchor.title, '/home/user/project/lib.d.ts#L42');
assert.strictEqual(anchor.title, `${fileUri.fsPath}#L42`);
});
test('Should not override explicit title for file:// links', () => {
const md = new MarkdownString(`[log](file:///home/user/project/lib.d.ts "Go to definition")`, {});
const fileUri = URI.file('/home/user/project/lib.d.ts');
const md = new MarkdownString(`[log](${fileUri.toString()} "Go to definition")`, {});
const result = store.add(renderMarkdown(md)).element;
const anchor = result.querySelector('a')!;