Skip to content

Commit 4e5d971

Browse files
authored
Merge pull request #298 from recca0120/feat/document-links
Feat/document links
2 parents aa13265 + cb68e81 commit 4e5d971

10 files changed

Lines changed: 282 additions & 191 deletions

__mocks__/vscode.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import { glob } from 'glob';
22
import { minimatch } from 'minimatch';
33
import { readFile } from 'node:fs/promises';
44
import {
5-
CancellationToken, DocumentFilter, MarkdownString, TestController, TestItem, TestItemCollection,
6-
TestRunRequest as BaseTestRunRequest, TestTag, TextDocument, WorkspaceFolder, TestCoverageCount,
5+
CancellationToken, DocumentFilter, MarkdownString, TestController, TestCoverageCount, TestItem, TestItemCollection,
6+
TestRunRequest as BaseTestRunRequest, TestTag, TextDocument, WorkspaceFolder,
77
} from 'vscode';
88
import { URI } from 'vscode-uri';
99

@@ -168,7 +168,17 @@ const Range = jest.fn().mockImplementation((start: any, end: any) => {
168168
});
169169

170170
const Position = jest.fn().mockImplementation((line: number, character: number) => {
171-
return { line, character };
171+
return {
172+
line,
173+
character,
174+
translate: (lineDelta?: number, characterDelta?: number) => {
175+
return new Position(line + (lineDelta ?? 0), characterDelta ?? character);
176+
},
177+
};
178+
});
179+
180+
const DocumentLink = jest.fn().mockImplementation((range: Range, target?: URI) => {
181+
return { range, target };
172182
});
173183

174184
const CancellationTokenSource = jest.fn().mockImplementation(() => {
@@ -262,6 +272,7 @@ const languages = {
262272

263273
return minimatch(document.uri.fsPath, pattern) ? 10 : 0;
264274
},
275+
registerDocumentLinkProvider: jest.fn(),
265276
};
266277

267278
const RelativePattern = jest
@@ -316,7 +327,7 @@ const extensions = {
316327
};
317328

318329
class FileCoverage {
319-
constructor(public uri:URI, public statementCoverage: TestCoverageCount) {}
330+
constructor(public uri: URI, public statementCoverage: TestCoverageCount) {}
320331
}
321332

322333
class TestCoverageCount {
@@ -349,4 +360,5 @@ export {
349360
FileCoverage,
350361
TestCoverageCount,
351362
StatementCoverage,
363+
DocumentLink,
352364
};

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ module.exports = {
170170
// A map from regular expressions to paths to transformers
171171
// transform: undefined,
172172
transform: {
173-
'^.+.tsx?$': ['ts-jest', { isolatedModules: true }],
173+
'^.+.tsx?$': ['ts-jest'],
174174
},
175175

176176
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation

0 commit comments

Comments
 (0)