diff --git a/ts/deckoptions/steps.test.ts b/ts/deckoptions/steps.test.ts index 9bc33eaba..bd7b82025 100644 --- a/ts/deckoptions/steps.test.ts +++ b/ts/deckoptions/steps.test.ts @@ -9,6 +9,7 @@ test("whole steps", () => { expect(stepsToString(steps)).toBe(string); expect(stringToSteps(string)).toStrictEqual(steps); }); + test("fractional steps", () => { const steps = [1 / 60, 5 / 60, 1.5, 400]; const string = "1s 5s 90s 400m"; @@ -16,6 +17,11 @@ test("fractional steps", () => { expect(stringToSteps(string)).toStrictEqual(steps); }); +test("rounding", () => { + const steps = [0.1666666716337204]; + expect(stepsToString(steps)).toBe("10s"); +}); + test("parsing", () => { expect(stringToSteps("")).toStrictEqual([]); expect(stringToSteps(" ")).toStrictEqual([]); diff --git a/ts/deckoptions/steps.ts b/ts/deckoptions/steps.ts index 856ecbc87..36a3c1757 100644 --- a/ts/deckoptions/steps.ts +++ b/ts/deckoptions/steps.ts @@ -38,7 +38,7 @@ function minutesToString(step: number): string { if ([TimespanUnit.Months, TimespanUnit.Years].includes(unit)) { unit = TimespanUnit.Days; } - const amount = unitAmount(unit, secs); + const amount = Math.round(unitAmount(unit, secs)); return `${amount}${unitSuffix(unit)}`; }