Skip to content

Commit ebef7eb

Browse files
committed
Test every valid clock input
Exercise all 1,440 valid HH:mm values against the 12-hour output.
1 parent 153637b commit ebef7eb

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎format-clock-edge-cases/timeConverter.test.js‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,16 @@ for (const [time, expected] of cases) {
2222
assert.equal(formatAs12HourClock(time), expected);
2323
});
2424
}
25+
26+
test("converts every valid minute of the day", () => {
27+
for (let hour = 0; hour < 24; hour += 1) {
28+
for (let minute = 0; minute < 60; minute += 1) {
29+
const time = `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`;
30+
const convertedHour = hour % 12 || 12;
31+
const period = hour < 12 ? "am" : "pm";
32+
const expected = `${String(convertedHour).padStart(2, "0")}:${String(minute).padStart(2, "0")} ${period}`;
33+
34+
assert.equal(formatAs12HourClock(time), expected, time);
35+
}
36+
}
37+
});

0 commit comments

Comments
 (0)