diff --git a/frontend/src/components/TypingSpeedGame.unit.test.js b/frontend/src/components/TypingSpeedGame.unit.test.js index 89c7fe61..8326f8ea 100644 --- a/frontend/src/components/TypingSpeedGame.unit.test.js +++ b/frontend/src/components/TypingSpeedGame.unit.test.js @@ -1,5 +1,9 @@ import { describe, expect, it } from "vitest"; -import { calculateWpm, calculateAccuracy } from "./typingSpeedHelpers"; +import { + calculateWpm, + calculateAccuracy, + formatTime, +} from "./typingSpeedHelpers"; describe("TypingSpeedGame helpers", () => { it("calculates WPM correctly for positive correct chars and seconds", () => { @@ -23,4 +27,11 @@ describe("TypingSpeedGame helpers", () => { expect(calculateAccuracy(0, 0)).toBe(100); expect(calculateAccuracy(0, -1)).toBe(100); }); + + it("formats time correctly", () => { + expect(formatTime(0)).toBe("00:00"); + expect(formatTime(9)).toBe("00:09"); + expect(formatTime(60)).toBe("01:00"); + expect(formatTime(125)).toBe("02:05"); + }); });