|
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 corectly convert midnight", () => |
| 14 | + assert.equal(formatAs12HourClock("00:00"), "12:00 am")); |
| 15 | + |
| 16 | +test("can corectly convert mid-day", () => |
| 17 | + assert.equal(formatAs12HourClock("12:00"), "12:00 pm")); |
| 18 | + |
| 19 | +test("can corectly convert half an hour passed midnight", () => |
| 20 | + assert.equal(formatAs12HourClock("00:30"), "00:30 am")); |
| 21 | + |
| 22 | +test("can correctly convert time with missing leading zero", function () { |
| 23 | + assert.equal(formatAs12HourClock("9:00"), "09:00 am"); |
| 24 | +}); |
| 25 | + |
| 26 | +test("can correctly handel non digit format entries", function () { |
| 27 | + assert.equal(formatAs12HourClock("nineOclock"), "Inccorect timing format"); |
| 28 | +}); |
| 29 | +/* ************************ Edge cases Minutes *****************************************************/ |
| 30 | +/* over one hour <- 60 30 0 -> negative number */ |
| 31 | +/* <----------------|---------------------------|---------------------------------------|-------------------> */ |
| 32 | +/* **************************************************************************************************************/ |
| 33 | + |
| 34 | +/* ************************ Edge cases Hours *****************************************************/ |
| 35 | +/* over one day <- 24 12 0 -> negative number */ |
| 36 | +/* <----------------|---------------------------|---------------------------------------|-------------------> */ |
| 37 | +/* **************************************************************************************************************/ |
| 38 | + |
| 39 | +/*--------------------------------------------| |
| 40 | + | Hours | Minures | |
| 41 | + | 00 | 00 | |
| 42 | + |___________________|___________________ ___| |
| 43 | + |
| 44 | + |
| 45 | + * |
| 46 | +
|
| 47 | + */ |
0 commit comments