@@ -2,24 +2,46 @@ import { formatAs12HourClock } from "./timeConverter.js";
22import assert from "node:assert" ;
33import test from "node:test" ;
44
5- const cases = [
6- [ "08:00" , "08:00 AM" ] ,
7- [ "23:00" , "11:00 PM" ] ,
8- [ "15:30" , "03:30 PM" ] ,
9- [ "12:10" , "12:10 PM" ] ,
10- [ "08:45" , "08:45 AM" ] ,
11- [ "09:05" , "09:05 AM" ] ,
12- [ "17:45" , "05:45 PM" ] ,
13- [ "00:00" , "12:00 AM" ] ,
14- [ "11:59" , "11:59 AM" ] ,
15- [ "23:59" , "11:59 PM" ] ,
16- ] ;
17-
18- cases . forEach ( ( [ input , expected ] ) => {
19- const output = formatAs12HourClock ( input ) ;
20- if ( output === expected ) {
21- console . log ( `✅ ${ input } → returned "${ output } "` ) ;
22- } else {
23- console . error ( `❌ ${ input } → returned "${ output } ", expected "${ expected } "` ) ;
24- }
5+ test ( "correctly convert 08:00 to morning time" , function ( ) {
6+ assert . equal ( formatAs12HourClock ( "08:00" ) , "08:00 am" ) ;
7+ } ) ;
8+
9+ test ( "correctly convert 23:00 to evening time" , function ( ) {
10+ assert . equal ( formatAs12HourClock ( "23:00" ) , "11:00 pm" ) ;
11+ } ) ;
12+
13+ test ( "correctly convert 15:30 to afternoon time" , function ( ) {
14+ assert . equal ( formatAs12HourClock ( "15:30" ) , "03:30 pm" ) ;
15+ } ) ;
16+
17+ test ( "correctly convert 12:10 to 10 past noon time" , function ( ) {
18+ assert . equal ( formatAs12HourClock ( "12:10" ) , "12:10 pm" ) ;
19+ } ) ;
20+
21+ test ( "correctly convert 12:00 to exactly noon time" , function ( ) {
22+ assert . equal ( formatAs12HourClock ( "12:00" ) , "12:00 pm" ) ;
23+ } ) ;
24+
25+ test ( "correctly convert 08:45 to morning time" , function ( ) {
26+ assert . equal ( formatAs12HourClock ( "08:45" ) , "08:45 am" ) ;
27+ } ) ;
28+
29+ test ( "correctly convert 09:05 to morning time" , function ( ) {
30+ assert . equal ( formatAs12HourClock ( "09:05" ) , "09:05 am" ) ;
31+ } ) ;
32+
33+ test ( "correctly convert 17:45 to evening time" , function ( ) {
34+ assert . equal ( formatAs12HourClock ( "17:45" ) , "05:45 pm" ) ;
35+ } ) ;
36+
37+ test ( "correctly convert midnight 00:00" , function ( ) {
38+ assert . equal ( formatAs12HourClock ( "00:00" ) , "12:00 am" ) ;
39+ } ) ;
40+
41+ test ( "correctly convert 11:59 to late morning time" , function ( ) {
42+ assert . equal ( formatAs12HourClock ( "11:59" ) , "11:59 am" ) ;
43+ } ) ;
44+
45+ test ( "correctly convert 23:59 to late night time" , function ( ) {
46+ assert . equal ( formatAs12HourClock ( "23:59" ) , "11:59 pm" ) ;
2547} ) ;
0 commit comments