Skip to content

Commit dbad16a

Browse files
committed
added edge case tests for time converter function
1 parent 29ef74a commit dbad16a

1 file changed

Lines changed: 37 additions & 5 deletions

File tree

Lines changed: 37 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,43 @@
1-
import {formatAs12HourClock} from "./timeConverter.js";
1+
import { formatAs12HourClock } from "./timeConverter.js";
22
import assert from "node:assert";
33
import test from "node:test";
44

5-
test("correctly convert time after 12:00", function(){
6-
assert.equal(formatAs12HourClock("23:00"), "11:00 pm");
5+
test("correctly convert time after 12:00", function () {
6+
assert.equal(formatAs12HourClock("23:00"), "11:00 pm");
77
});
88

9-
test("can correctly convert morning time", function() {
10-
assert.equal(formatAs12HourClock("08:00"), "08:00 am");
9+
test("can correctly convert morning time", function () {
10+
assert.equal(formatAs12HourClock("08:00"), "08:00 am");
11+
});
12+
13+
test("can correctly convert midnight", function () {
14+
assert.equal(formatAs12HourClock("00:00"), "12:00 am");
15+
});
16+
17+
test("correctly convert time 1 hour before 12:00", function () {
18+
assert.equal(formatAs12HourClock("11:00"), "11:00 am");
19+
});
20+
21+
test("correctly convert time 2 hours before 12:00", function () {
22+
assert.equal(formatAs12HourClock("10:00"), "10:00 am");
23+
});
24+
25+
test("correctly convert time 3 hours before 12:00", function () {
26+
assert.equal(formatAs12HourClock("09:00"), "09:00 am");
27+
});
28+
29+
test("can correctly convert every half hour before 12:00", function () {
30+
assert.equal(formatAs12HourClock("09:30"), "09:30 am");
31+
});
32+
33+
test("can correctly convert hours in the afternoon", function () {
34+
assert.equal(formatAs12HourClock("13:00"), "1:00 pm");
35+
});
36+
37+
test("correctly convert half hour after 12:00", function () {
38+
assert.equal(formatAs12HourClock("13:30"), "1:30 pm");
39+
});
40+
41+
test("correctly convert half hour after 12:00", function () {
42+
assert.equal(formatAs12HourClock("23:30"), "11:30 pm");
1143
});

0 commit comments

Comments
 (0)