From e9af27103bd0b00b5894d57a765d658458fe395f Mon Sep 17 00:00:00 2001 From: Janne Savolainen Date: Thu, 2 Jun 2022 11:20:37 +0300 Subject: [PATCH] Round percentage of update download progress in tray Co-authored-by: Mikko Aspiala Signed-off-by: Janne Savolainen --- .../application-update/installing-update-using-tray.test.ts | 4 ++-- .../check-for-updates-tray-item.injectable.ts | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/behaviours/application-update/installing-update-using-tray.test.ts b/src/behaviours/application-update/installing-update-using-tray.test.ts index ad5d8cb44d..f6570bb8fa 100644 --- a/src/behaviours/application-update/installing-update-using-tray.test.ts +++ b/src/behaviours/application-update/installing-update-using-tray.test.ts @@ -154,12 +154,12 @@ describe("installing update using tray", () => { ).toBe("Downloading update some-version (0%)..."); }); - it("when download progresses, percentage increases", () => { + it("when download progresses with decimals, percentage increases as integers", () => { const progressOfUpdateDownload = applicationBuilder.dis.mainDi.inject( progressOfUpdateDownloadInjectable, ); - progressOfUpdateDownload.set({ percentage: 42 }); + progressOfUpdateDownload.set({ percentage: 42.424242 }); expect( applicationBuilder.tray.get("check-for-updates")?.label?.get(), diff --git a/src/main/application-update/check-for-updates-tray-item.injectable.ts b/src/main/application-update/check-for-updates-tray-item.injectable.ts index 14b9de155d..5ff4be731a 100644 --- a/src/main/application-update/check-for-updates-tray-item.injectable.ts +++ b/src/main/application-update/check-for-updates-tray-item.injectable.ts @@ -41,7 +41,9 @@ const checkForUpdatesTrayItemInjectable = getInjectable({ assert(discoveredVersion); - return `Downloading update ${discoveredVersion.version} (${progressOfUpdateDownload.value.get().percentage}%)...`; + const roundedPercentage = Math.round(progressOfUpdateDownload.value.get().percentage); + + return `Downloading update ${discoveredVersion.version} (${roundedPercentage}%)...`; } if (checkingForUpdatesState.value.get()) {