From 7fe0958a821071f713b1900f4d3f358f10cf0b46 Mon Sep 17 00:00:00 2001 From: Mohamed Khelif Date: Tue, 12 Dec 2023 16:17:47 -0500 Subject: [PATCH] DEVPROD-820 Support displaying sub 1s durations on the tests table (#2187) --- src/utils/string/index.ts | 1 + src/utils/string/string.test.ts | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/utils/string/index.ts b/src/utils/string/index.ts index c19572ae7c..423024e5ee 100644 --- a/src/utils/string/index.ts +++ b/src/utils/string/index.ts @@ -28,6 +28,7 @@ export const msToDuration = (ms: number): string => { if (seconds > 0) { return `${seconds}s`; } + return `${ms}ms`; }; /** diff --git a/src/utils/string/string.test.ts b/src/utils/string/string.test.ts index 35b0197f13..bbb219de24 100644 --- a/src/utils/string/string.test.ts +++ b/src/utils/string/string.test.ts @@ -44,6 +44,10 @@ describe("msToDuration", () => { const ms = 25000; expect(msToDuration(ms)).toBe("25s"); }); + it("does not convert milli < 1s", () => { + const ms = 500; + expect(msToDuration(ms)).toBe("500ms"); + }); }); describe("sortFunctionDate", () => {