diff --git a/src/extension/statusbartoggler.ts b/src/extension/statusbartoggler.ts index e3c6ff0..dbc2bf1 100644 --- a/src/extension/statusbartoggler.ts +++ b/src/extension/statusbartoggler.ts @@ -2,18 +2,24 @@ import { Disposable, StatusBarItem, window } from "vscode"; import { Config } from "./config"; export class StatusBarToggler implements Disposable { - private static readonly coverageText = "Coverage"; - - private static readonly loadingText = ["$(loading~spin)", StatusBarToggler.coverageText].join(" "); + private static readonly loadingText = ["$(loading~spin)", "Coverage"].join( + " " + ); private static readonly idleIcon = "$(circle-large-outline)"; - private static readonly watchCommand = "coverage-gutters.watchCoverageAndVisibleEditors"; - private static readonly watchText = [StatusBarToggler.idleIcon, "Watch"].join(" "); - private static readonly watchToolTip = "Coverage Gutters: Click to watch workspace."; + private static readonly watchCommand = + "coverage-gutters.watchCoverageAndVisibleEditors"; + private static readonly watchText = [ + StatusBarToggler.idleIcon, + "Watch", + ].join(" "); + private static readonly watchToolTip = + "Coverage Gutters: Click to watch workspace."; private static readonly removeCommand = "coverage-gutters.removeWatch"; - private static readonly removeWatchToolTip = "Coverage Gutters: Click to remove watch from workspace."; + private static readonly removeWatchToolTip = + "Coverage Gutters: Click to remove watch from workspace."; public isActive: boolean | undefined; public isLoading: boolean; @@ -30,7 +36,9 @@ export class StatusBarToggler implements Disposable { this.isLoading = false; this.lineCoverage = undefined; - if (this.configStore.showStatusBarToggler) { this.statusBarItem.show(); } + if (this.configStore.showStatusBarToggler) { + this.statusBarItem.show(); + } } public get statusText() { @@ -51,7 +59,7 @@ export class StatusBarToggler implements Disposable { this.update(); } - public setCoverage(linePercentage: number | undefined ) { + public setCoverage(linePercentage: number | undefined) { if (Number.isFinite(linePercentage)) { this.lineCoverage = `${linePercentage}%`; } else { @@ -72,7 +80,13 @@ export class StatusBarToggler implements Disposable { return StatusBarToggler.loadingText; } if (this.isActive) { - return [StatusBarToggler.idleIcon, this.lineCoverage || "No", StatusBarToggler.coverageText].join(" "); + const activeText = [StatusBarToggler.idleIcon, "File"]; + if (this.lineCoverage && this.lineCoverage !== "0%") { + activeText.push(this.lineCoverage, "Covered"); + } else { + activeText.push("Uncovered"); + } + return activeText.join(" "); } return StatusBarToggler.watchText; } diff --git a/test/extension/statusbartoggler.test.ts b/test/extension/statusbartoggler.test.ts index 79810d5..e9bdd8d 100644 --- a/test/extension/statusbartoggler.test.ts +++ b/test/extension/statusbartoggler.test.ts @@ -9,48 +9,74 @@ suite("Status Bar Toggler Tests", () => { test("Should toggle showStatusBarToggler command and message @unit", () => { const statusBarToggler = new StatusBarToggler(stubConfig); statusBarToggler.toggle(true); - expect(statusBarToggler.statusText).to.equal("$(circle-large-outline) No Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(circle-large-outline) File Uncovered" + ); }); test("Should not toggle twice showStatusBarToggler command and message @unit", () => { const statusBarToggler = new StatusBarToggler(stubConfig); statusBarToggler.toggle(true); - expect(statusBarToggler.statusText).to.equal("$(circle-large-outline) No Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(circle-large-outline) File Uncovered" + ); statusBarToggler.toggle(true); - expect(statusBarToggler.statusText).to.equal("$(circle-large-outline) No Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(circle-large-outline) File Uncovered" + ); }); - test("Should toggle showStatusBarToggler command and message back to \"Watch\" @unit", () => { + test('Should toggle showStatusBarToggler command and message back to "Watch" @unit', () => { const statusBarToggler = new StatusBarToggler(stubConfig); statusBarToggler.toggle(true); - expect(statusBarToggler.statusText).to.equal("$(circle-large-outline) No Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(circle-large-outline) File Uncovered" + ); statusBarToggler.toggle(false); - expect(statusBarToggler.statusText).to.equal("$(circle-large-outline) Watch"); + expect(statusBarToggler.statusText).to.equal( + "$(circle-large-outline) Watch" + ); }); test("Should show the spinner when setting the `isLoading` status @unit", () => { const statusBarToggler = new StatusBarToggler(stubConfig); statusBarToggler.setLoading(true); - expect(statusBarToggler.statusText).to.equal("$(loading~spin) Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(loading~spin) Coverage" + ); statusBarToggler.toggle(true); - expect(statusBarToggler.statusText).to.equal("$(loading~spin) Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(loading~spin) Coverage" + ); statusBarToggler.setLoading(false); - expect(statusBarToggler.statusText).to.equal("$(circle-large-outline) No Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(circle-large-outline) File Uncovered" + ); }); test("Should show coverage when a number is set @unit", () => { const statusBarToggler = new StatusBarToggler(stubConfig); statusBarToggler.toggle(true); statusBarToggler.setLoading(false); - expect(statusBarToggler.statusText).to.equal("$(circle-large-outline) No Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(circle-large-outline) File Uncovered" + ); statusBarToggler.setCoverage(84); - expect(statusBarToggler.statusText).to.equal("$(circle-large-outline) 84% Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(circle-large-outline) File 84% Covered" + ); statusBarToggler.setCoverage(undefined); - expect(statusBarToggler.statusText).to.equal("$(circle-large-outline) No Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(circle-large-outline) File Uncovered" + ); statusBarToggler.setCoverage(50); - expect(statusBarToggler.statusText).to.equal("$(circle-large-outline) 50% Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(circle-large-outline) File 50% Covered" + ); statusBarToggler.setCoverage(0); - expect(statusBarToggler.statusText).to.equal("$(circle-large-outline) 0% Coverage"); + expect(statusBarToggler.statusText).to.equal( + "$(circle-large-outline) File Uncovered" + ); }); test("Should dispose when asked @unit", () => {