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

feat: Add toggle command #385

Merged
merged 6 commits into from
Nov 26, 2022
Merged
Changes from 1 commit
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
Prev Previous commit
test: Toggle coverage integration test (#1)
  • Loading branch information
ryanluker authored Nov 21, 2022
commit 91f473527f777f5b7c1940b129760c8a59954044
38 changes: 38 additions & 0 deletions test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,44 @@ suite("Extension Tests", function() {
expect(cachedLines.none).to.have.lengthOf(3);
});

await vscode.commands.executeCommand("coverage-gutters.removeCoverage");
decorationSpy.restore();
});

test("Run toggle coverage on python test file x2 @integration", async () => {
// Set up the spies to allow for detecting proper code flows
const decorationSpy = sinon.spy(Renderer.prototype, "setDecorationsForEditor");
const removalSpy = sinon.spy(Renderer.prototype, "removeDecorationsForEditor");
const extension = await vscode.extensions.getExtension("ryanluker.vscode-coverage-gutters");
if (!extension) {
throw new Error("Could not load extension");
}

const testCoverage = await vscode.workspace.findFiles("**/bar/a.py", "**/node_modules/**");
const testDocument = await vscode.workspace.openTextDocument(testCoverage[0]);
await vscode.window.showTextDocument(testDocument);

// Toggle coverage on
await vscode.commands.executeCommand("coverage-gutters.toggleCoverage");
await checkCoverage(() => {
// Look for exact coverage on the file
const cachedLines: ICoverageLines = decorationSpy.getCall(0).args[1];
expect(cachedLines.full).to.have.lengthOf(3);
expect(cachedLines.none).to.have.lengthOf(3);
});

// Toggle coverage off
await vscode.commands.executeCommand("coverage-gutters.toggleCoverage");
// Check that renderSections was called with empty Map
await checkCoverage(() => {
// Check for remove coverage being called twice
const coverageRemovalCalls = removalSpy.getCalls();
expect(coverageRemovalCalls).to.have.length(2);
// Check for the coverage display being called once
const coverageAdditionCalls = decorationSpy.getCalls();
expect(coverageAdditionCalls).to.have.length(1);
});

decorationSpy.restore();
});

Expand Down