@@ -11,7 +11,6 @@ import {
1111 type RoundPeriod ,
1212 generateReservableMap ,
1313 isRangeReservable ,
14- getDayIntervals ,
1514 isStartTimeValid ,
1615} from "../reservable" ;
1716import {
@@ -752,111 +751,3 @@ describe("isRangeReservable", () => {
752751 expect ( isRangeReservable ( input ) ) . toBe ( true ) ;
753752 } ) ;
754753} ) ;
755-
756- describe ( "getDayIntervals" , ( ) => {
757- test ( "getDayIntervals from 9 to 17 with 30 min interval" , ( ) => {
758- const input = {
759- startTime : { h : 9 , m : 0 } ,
760- endTime : { h : 17 , m : 0 } ,
761- interval : ReservationStartInterval . Interval_30Mins ,
762- } ;
763- const output : { h : number ; m : number } [ ] = [ ] ;
764- for ( let i = 9 ; i < 17 ; i ++ ) {
765- output . push ( { h : i , m : 0 } ) ;
766- output . push ( { h : i , m : 30 } ) ;
767- }
768- const res = getDayIntervals ( input . startTime , input . endTime , input . interval ) ;
769- expect ( res ) . toEqual ( output ) ;
770- } ) ;
771- test ( "getDayIntervals from 9 to 17 with 15 min interval" , ( ) => {
772- const input = {
773- startTime : { h : 9 , m : 0 } ,
774- endTime : { h : 17 , m : 0 } ,
775- interval : ReservationStartInterval . Interval_15Mins ,
776- } ;
777- const output : { h : number ; m : number } [ ] = [ ] ;
778- for ( let i = 9 ; i < 17 ; i ++ ) {
779- output . push ( { h : i , m : 0 } ) ;
780- output . push ( { h : i , m : 15 } ) ;
781- output . push ( { h : i , m : 30 } ) ;
782- output . push ( { h : i , m : 45 } ) ;
783- }
784- const res = getDayIntervals ( input . startTime , input . endTime , input . interval ) ;
785- expect ( res ) . toEqual ( output ) ;
786- } ) ;
787- test ( "getDayIntervals from 9 to 17 with 60 min interval" , ( ) => {
788- const input = {
789- startTime : { h : 9 , m : 0 } ,
790- endTime : { h : 17 , m : 0 } ,
791- interval : ReservationStartInterval . Interval_60Mins ,
792- } ;
793- const output : { h : number ; m : number } [ ] = [ ] ;
794- for ( let i = 9 ; i < 17 ; i ++ ) {
795- output . push ( { h : i , m : 0 } ) ;
796- }
797- const res = getDayIntervals ( input . startTime , input . endTime , input . interval ) ;
798- expect ( res ) . toEqual ( output ) ;
799- } ) ;
800- test ( "getDayIntervals from 0 to 24 with 30 min interval" , ( ) => {
801- const input = {
802- startTime : { h : 0 , m : 0 } ,
803- endTime : { h : 24 , m : 0 } ,
804- interval : ReservationStartInterval . Interval_30Mins ,
805- } ;
806- const output : { h : number ; m : number } [ ] = [ ] ;
807- for ( let i = 0 ; i < 24 ; i ++ ) {
808- output . push ( { h : i , m : 0 } ) ;
809- output . push ( { h : i , m : 30 } ) ;
810- }
811- const res = getDayIntervals ( input . startTime , input . endTime , input . interval ) ;
812- expect ( res ) . toEqual ( output ) ;
813- } ) ;
814- test ( "getDayIntervals with invalid range" , ( ) => {
815- const input = {
816- startTime : { h : 17 , m : 0 } ,
817- endTime : { h : 9 , m : 0 } ,
818- interval : ReservationStartInterval . Interval_30Mins ,
819- } ;
820- const res = getDayIntervals ( input . startTime , input . endTime , input . interval ) ;
821- expect ( res ) . toEqual ( [ ] ) ;
822- } ) ;
823- test ( "getDayIntervals with 0 size range" , ( ) => {
824- const input = {
825- startTime : { h : 17 , m : 0 } ,
826- endTime : { h : 17 , m : 0 } ,
827- interval : ReservationStartInterval . Interval_30Mins ,
828- } ;
829- const res = getDayIntervals ( input . startTime , input . endTime , input . interval ) ;
830- expect ( res ) . toEqual ( [ ] ) ;
831- } ) ;
832- test ( "getDayIntervals with uneven times" , ( ) => {
833- const input = {
834- startTime : { h : 9 , m : 20 } ,
835- endTime : { h : 17 , m : 20 } ,
836- interval : ReservationStartInterval . Interval_30Mins ,
837- } ;
838- const output : { h : number ; m : number } [ ] = [ ] ;
839- for ( let i = 9 ; i < 17 ; i ++ ) {
840- output . push ( { h : i , m : 20 } ) ;
841- output . push ( { h : i , m : 50 } ) ;
842- }
843- const res = getDayIntervals ( input . startTime , input . endTime , input . interval ) ;
844- expect ( res ) . toEqual ( output ) ;
845- } ) ;
846- test ( "getDayIntervals with uneven times" , ( ) => {
847- const input = {
848- startTime : { h : 9 , m : 20 } ,
849- endTime : { h : 17 , m : 0 } ,
850- interval : ReservationStartInterval . Interval_30Mins ,
851- } ;
852- const output : { h : number ; m : number } [ ] = [ ] ;
853- for ( let i = 9 ; i < 17 ; i ++ ) {
854- output . push ( { h : i , m : 20 } ) ;
855- if ( i < 16 ) {
856- output . push ( { h : i , m : 50 } ) ;
857- }
858- }
859- const res = getDayIntervals ( input . startTime , input . endTime , input . interval ) ;
860- expect ( res ) . toEqual ( output ) ;
861- } ) ;
862- } ) ;
0 commit comments