Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(preview): pass vscode.uri to live preview #394

Merged
merged 2 commits into from
Feb 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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");
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing the tests as well!
Looks like everything is passing here 🦾.
https://github.com/ryanluker/vscode-coverage-gutters/actions/runs/4270550605/jobs/7434653819

});
});