-
Notifications
You must be signed in to change notification settings - Fork 427
Expand file tree
/
Copy pathstackTraceLinkProvider.test.ts
More file actions
51 lines (40 loc) · 1.78 KB
/
Copy pathstackTraceLinkProvider.test.ts
File metadata and controls
51 lines (40 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT license.
import * as assert from "assert";
import { CancellationTokenSource, workspace } from "vscode";
import { JavaStackTraceLinkProvider } from "../src/stackTraceLinkProvider";
suite("JavaStackTraceLinkProvider", () => {
async function provideLinks(content: string) {
const document = await workspace.openTextDocument({ language: "log", content });
const cancellation = new CancellationTokenSource();
try {
return await Promise.resolve(
new JavaStackTraceLinkProvider().provideDocumentLinks(document, cancellation.token),
);
} finally {
cancellation.dispose();
}
}
test("encodes command URI arguments as an array", async () => {
const stackTrace = "com.example.App.main(App.java:42)";
const links = await provideLinks(`\tat ${stackTrace}`);
assert.ok(links);
assert.strictEqual(links.length, 1);
const target = links[0].target;
assert.ok(target);
assert.deepStrictEqual(JSON.parse(decodeURIComponent(target.query)), [{
stackTrace,
methodName: "com.example.App.main",
lineNumber: 42,
}]);
});
test("stops scanning after the document character budget", async () => {
const longPrefix = `${"x".repeat(1000)}\n`.repeat(1000);
const links = await provideLinks(`${longPrefix}\tat com.example.App.main(App.java:42)`);
assert.deepStrictEqual(links, []);
});
test("stops scanning after the document line budget", async () => {
const links = await provideLinks(`${"\n".repeat(10000)}\tat com.example.App.main(App.java:42)`);
assert.deepStrictEqual(links, []);
});
});