-
Notifications
You must be signed in to change notification settings - Fork 102
Expand file tree
/
Copy pathextension.test.ts
More file actions
55 lines (46 loc) · 2.34 KB
/
extension.test.ts
File metadata and controls
55 lines (46 loc) · 2.34 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
52
53
54
55
import * as assert from "assert";
import * as vscode from "vscode";
import {ICoverageLines} from "../src/renderer";
suite("Extension Tests", function() {
this.timeout(25000);
test("Should start extension @integration", async () => {
const started = vscode.extensions.getExtension(
"ryanluker.vscode-coverage-gutters",
).isActive;
assert.equal(started, true);
});
test("Run display coverage on node test file @integration", async () => {
const extension = await vscode.extensions.getExtension("ryanluker.vscode-coverage-gutters");
const getCachedLines = extension.exports;
const testCoverage = await vscode.workspace.findFiles("**/test-coverage.js", "**/node_modules/**");
const testDocument = await vscode.workspace.openTextDocument(testCoverage[0]);
const testEditor = await vscode.window.showTextDocument(testDocument);
await vscode.commands.executeCommand("extension.displayCoverage");
// Wait for decorations to load
// TODO: need a better way to do this...
await sleep(2000);
// Look for exact coverage on the file
const cachedLines: ICoverageLines = getCachedLines();
assert.equal(14, cachedLines.full.length);
assert.equal(4, cachedLines.none.length);
assert.equal(7, cachedLines.partial.length);
});
test("Run display coverage on python test file @integration", async () => {
const extension = await vscode.extensions.getExtension("ryanluker.vscode-coverage-gutters");
const getCachedLines = extension.exports;
const testCoverage = await vscode.workspace.findFiles("**/bar/a.py", "**/node_modules/**");
const testDocument = await vscode.workspace.openTextDocument(testCoverage[0]);
const testEditor = await vscode.window.showTextDocument(testDocument);
await vscode.commands.executeCommand("extension.displayCoverage");
// Wait for decorations to load
// TODO: need a better way to do this...
await sleep(2000);
// Look for exact coverage on the file
const cachedLines: ICoverageLines = getCachedLines();
assert.equal(3, cachedLines.full.length);
assert.equal(3, cachedLines.none.length);
});
});
async function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms));
}