|
1 | | -import {formatAs12HourClock} from "./timeConverter.js"; |
| 1 | +import { formatAs12HourClock } from "./timeConverter.js"; |
2 | 2 | import assert from "node:assert"; |
3 | 3 | import test from "node:test"; |
4 | 4 |
|
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"); |
7 | 7 | }); |
8 | 8 |
|
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 | 11 | }); |
| 12 | + |
| 13 | +test("can correctly convert midnight with double digit minutes", function () { |
| 14 | + assert.equal(formatAs12HourClock("00:25"), "12:25 am"); |
| 15 | +}); |
| 16 | + |
| 17 | +test("can correctly convert noon with the double digits minutes ", function () { |
| 18 | + assert.equal(formatAs12HourClock("12:20"), "12:20 pm"); |
| 19 | +}); |
| 20 | + |
| 21 | +test("can correctly convert evening with single-digit minutes", function () { |
| 22 | + assert.equal(formatAs12HourClock("23:05"), "11:05 pm"); |
| 23 | +}); |
| 24 | + |
| 25 | +test("can correctly convert one minute before noon", function () { |
| 26 | + assert.equal(formatAs12HourClock("11:59"), "11:59 am"); |
| 27 | +}); |
| 28 | + |
| 29 | +test("can correctly convert one hour after noon", function () { |
| 30 | + assert.equal(formatAs12HourClock("13:00"), "01:00 pm"); |
| 31 | +}); |
| 32 | +// It's a failing case also we need to complete it |
| 33 | +// test("does not need to convert a string.", function () { |
| 34 | +// assert.equal(formatAs12HourClock("Hello"), "NAN"); |
| 35 | +// }); |
| 36 | + |
| 37 | +// test("throws an error for hours above 23", function () { |
| 38 | +// assert.equal(formatAs12HourClock("25:00"), " Out of time"); |
| 39 | +// }); |
0 commit comments