Skip to content

Commit 97cb60f

Browse files
authored
Merge pull request #394 from kaltepeter/fix-preview
fix(preview): pass vscode.uri to live preview
2 parents 12e7058 + cfbc08d commit 97cb60f

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/coverage-system/coverage.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
window,
77
workspace,
88
WorkspaceFolder,
9+
Uri
910
} from "vscode";
1011

1112
import { Config } from "../extension/config";
@@ -22,7 +23,7 @@ export class Coverage {
2223
* Displays the quick picker vscode modal and lets the user choose a file path
2324
* Note: if only one path is given it will return early and not prompt.
2425
*/
25-
public async pickFile(filePaths: string[] | string, placeHolder: string): Promise<string | undefined> {
26+
public async pickFile(filePaths: string[] | string, placeHolder: string): Promise<Uri | undefined> {
2627
let pickedFile: string | undefined;
2728
if (typeof filePaths === "string") {
2829
pickedFile = filePaths;
@@ -47,7 +48,7 @@ export class Coverage {
4748

4849
pickedFile = item.description;
4950
}
50-
return pickedFile;
51+
return pickedFile ? Uri.file(pickedFile) : undefined;
5152
}
5253

5354
public findReports(): Promise<string[]> {

test/coverage-system/coverage.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,22 +63,22 @@ suite("Coverage Tests", () => {
6363
expect(stubWarningMessage.calledWith("Did not choose a file!"));
6464
});
6565

66-
test("#pickFile: Should return string if filePaths is a string @unit", async () => {
66+
test("#pickFile: Should return vscode.uri if filePaths is a string @unit", async () => {
6767
const coverage = new Coverage(
6868
stubConfig,
6969
);
7070

7171
const value = await coverage.pickFile("123", "nope");
7272

73-
expect(value).to.equal("123");
73+
expect(value?.path).to.equal("/123");
7474
});
7575

76-
test("#pickFile: Should return string if filePaths is an array with one value @unit", async () => {
76+
test("#pickFile: Should return vscode.uri if filePaths is an array with one value @unit", async () => {
7777
const coverage = new Coverage(
7878
stubConfig,
7979
);
8080

8181
const value = await coverage.pickFile(["123"], "nope");
82-
expect(value).to.equal("123");
82+
expect(value?.path).to.equal("/123");
8383
});
8484
});

0 commit comments

Comments
 (0)