@@ -100,14 +100,30 @@ test("get month time", () => {
100100 // 2022/05/02
101101 const now = new Date ( 2022 , 4 , 2 )
102102 const [ start , end ] = getMonthTime ( now )
103- expect ( start . toLocaleString ( ) ) . toEqual ( '2022/5/1 00:00:00' )
104- expect ( end . toLocaleString ( ) ) . toEqual ( '2022/5/31 23:59:59' )
103+ expect ( start . getMonth ( ) ) . toEqual ( 4 )
104+ expect ( start . getDate ( ) ) . toEqual ( 1 )
105+ expect ( start . getHours ( ) ) . toEqual ( 0 )
106+ expect ( start . getMinutes ( ) ) . toEqual ( 0 )
107+ expect ( start . getSeconds ( ) ) . toEqual ( 0 )
108+ expect ( start . getMilliseconds ( ) ) . toEqual ( 0 )
109+
110+ expect ( end . getMonth ( ) ) . toEqual ( 4 )
111+ expect ( end . getDate ( ) ) . toEqual ( 31 )
112+ expect ( end . getHours ( ) ) . toEqual ( 23 )
113+ expect ( end . getMinutes ( ) ) . toEqual ( 59 )
114+ expect ( end . getSeconds ( ) ) . toEqual ( 59 )
115+ expect ( end . getMilliseconds ( ) ) . toEqual ( 999 )
105116} )
106117
107118test ( "get start of day" , ( ) => {
108119 // 2022/05/22 11:30:29
109120 const now = new Date ( 2022 , 4 , 2 )
110121 now . setHours ( 11 , 30 , 29 , 999 )
111122 const start = getStartOfDay ( now )
112- expect ( start . toLocaleString ( ) ) . toEqual ( '2022/5/2 00:00:00' )
123+ expect ( start . getMonth ( ) ) . toEqual ( 4 )
124+ expect ( start . getDate ( ) ) . toEqual ( 2 )
125+ expect ( start . getHours ( ) ) . toEqual ( 0 )
126+ expect ( start . getMinutes ( ) ) . toEqual ( 0 )
127+ expect ( start . getSeconds ( ) ) . toEqual ( 0 )
128+ expect ( start . getMilliseconds ( ) ) . toEqual ( 0 )
113129} )
0 commit comments