[ARVADOS-WORKBENCH2] created: 2.2.1-80-gd906ace1

Git user git at public.arvados.org
Tue Sep 14 19:26:27 UTC 2021


        at  d906ace112bcacfaa91cdcf49815a70bd572ac2e (commit)


commit d906ace112bcacfaa91cdcf49815a70bd572ac2e
Author: Daniel Kutyła <daniel.kutyla at contractors.roche.com>
Date:   Tue Sep 14 21:25:35 2021 +0200

    16655: Fixed wrong speed indicator, added test
    
    Arvados-DCO-1.1-Signed-off-by: Daniel Kutyła <daniel.kutyla at contractors.roche.com>

diff --git a/src/common/formatters.test.ts b/src/common/formatters.test.ts
new file mode 100644
index 00000000..83177e22
--- /dev/null
+++ b/src/common/formatters.test.ts
@@ -0,0 +1,29 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { formatUploadSpeed } from "./formatters";
+
+describe('formatUploadSpeed', () => {
+    it('should show speed less than 1MB/s', () => {
+        // given
+        const speed = 900;
+
+        // when
+        const result = formatUploadSpeed(0, speed, 0, 1);
+
+        // then
+        expect(result).toBe('0.90 MB/s');
+    });
+
+    it('should show 5MB/s', () => {
+        // given
+        const speed = 5230;
+
+        // when
+        const result = formatUploadSpeed(0, speed, 0, 1);
+
+        // then
+        expect(result).toBe('5.23 MB/s');
+    }); 
+});
\ No newline at end of file
diff --git a/src/common/formatters.ts b/src/common/formatters.ts
index 779809f1..6d0a7e49 100644
--- a/src/common/formatters.ts
+++ b/src/common/formatters.ts
@@ -61,7 +61,8 @@ export function formatUploadSpeed(prevLoaded: number, loaded: number, prevTime:
     const speed = loaded > prevLoaded && currentTime > prevTime
         ? (loaded - prevLoaded) / (currentTime - prevTime)
         : 0;
-    return `${(speed / 1000).toFixed(2)} KB/s`;
+
+    return `${(speed / 1000).toFixed(2)} MB/s`;
 }
 
 const FILE_SIZES = [

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list