Skip to content

Commit fdef182

Browse files
committed
add tests for invalid time input handling
1 parent 9240183 commit fdef182

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

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

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,23 @@ test("can correctly convert midday time", function () {
1818
assert.equal(formatAs12HourClock("12:00"), "12:00 pm");
1919
});
2020

21-
test("can correctly convert 22:00 and 23:00 time", function () {
22-
assert.equal(formatAs12HourClock("22:00"), "10:00 pm");
21+
test("can respond to the invalid MM input", function () {
22+
assert.equal(
23+
formatAs12HourClock("22:60"),
24+
"Please check your MM input must be less than 60"
25+
);
26+
});
27+
28+
test("can respond to the invalid HH input", function () {
29+
assert.equal(
30+
formatAs12HourClock("24:00"),
31+
"Please check your HH input must be less than 24"
32+
);
33+
});
34+
35+
test("can respond to the invalid format input", function () {
36+
assert.equal(
37+
formatAs12HourClock("2400"),
38+
"Please check your format input must be 'HH:MM'"
39+
);
2340
});

0 commit comments

Comments
 (0)