From 48641f302802f8abdc4a224aaf3839a83fdf6aa2 Mon Sep 17 00:00:00 2001 From: Koen Kanters Date: Fri, 24 Apr 2020 22:38:51 +0200 Subject: [PATCH] Fix OTA percentage. #3422 --- lib/extension/otaUpdate.js | 2 +- test/otaUpdate.test.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/extension/otaUpdate.js b/lib/extension/otaUpdate.js index ae3ccd9e6..6809590a5 100644 --- a/lib/extension/otaUpdate.js +++ b/lib/extension/otaUpdate.js @@ -170,7 +170,7 @@ class OTAUpdate extends Extension { try { const onProgress = (progress, remaining) => { - let message = `Update of '${resolvedEntity.name}' at ${progress}%`; + let message = `Update of '${resolvedEntity.name}' at ${progress.toFixed(2)}%`; if (remaining) { message += `, +- ${Math.round(remaining / 60)} minutes remaining`; } diff --git a/test/otaUpdate.test.js b/test/otaUpdate.test.js index 60c7a32f9..8a78aaa3a 100644 --- a/test/otaUpdate.test.js +++ b/test/otaUpdate.test.js @@ -54,8 +54,8 @@ describe('OTA update', () => { expect(mapped.ota.isUpdateAvailable).toHaveBeenCalledTimes(0); expect(mapped.ota.updateToLatest).toHaveBeenCalledTimes(1); expect(mapped.ota.updateToLatest).toHaveBeenCalledWith(device, logger, expect.any(Function)); - expect(logger.info).toHaveBeenCalledWith(`Update of 'bulb' at 0%`); - expect(logger.info).toHaveBeenCalledWith(`Update of 'bulb' at 10%, +- 60 minutes remaining`); + expect(logger.info).toHaveBeenCalledWith(`Update of 'bulb' at 0.00%`); + expect(logger.info).toHaveBeenCalledWith(`Update of 'bulb' at 10.00%, +- 60 minutes remaining`); expect(logger.info).toHaveBeenCalledWith(`Finished update of 'bulb', from '{"softwareBuildID":1,"dateCode":"20190101"}' to '{"softwareBuildID":2,"dateCode":"20190102"}'`); expect(logger.error).toHaveBeenCalledTimes(0); expect(device.save).toHaveBeenCalledTimes(1);