Skip to content

Commit

Permalink
Merge pull request #394 from kaltepeter/fix-preview
Browse files Browse the repository at this point in the history
fix(preview): pass vscode.uri to live preview
  • Loading branch information
ryanluker authored Feb 25, 2023
2 parents 12e7058 + cfbc08d commit 97cb60f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
5 changes: 3 additions & 2 deletions src/coverage-system/coverage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
window,
workspace,
WorkspaceFolder,
Uri
} from "vscode";

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

pickedFile = item.description;
}
return pickedFile;
return pickedFile ? Uri.file(pickedFile) : undefined;
}

public findReports(): Promise<string[]> {
Expand Down
8 changes: 4 additions & 4 deletions test/coverage-system/coverage.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,22 +63,22 @@ suite("Coverage Tests", () => {
expect(stubWarningMessage.calledWith("Did not choose a file!"));
});

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

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

expect(value).to.equal("123");
expect(value?.path).to.equal("/123");
});

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

const value = await coverage.pickFile(["123"], "nope");
expect(value).to.equal("123");
expect(value?.path).to.equal("/123");
});
});

0 comments on commit 97cb60f

Please sign in to comment.