File tree 2 files changed +4
-4
lines changed
site/src/components/Timeline
2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -2,13 +2,13 @@ import { createDisplayDate } from "./TimelineDateRow"
2
2
3
3
describe ( "createDisplayDate" , ( ) => {
4
4
it ( "returns correctly for Saturdays" , ( ) => {
5
- const now = new Date ( )
5
+ const now = new Date ( 2020 , 1 , 7 )
6
6
const date = new Date (
7
7
now . getFullYear ( ) ,
8
8
now . getMonth ( ) ,
9
9
// Previous Saturday, from now.
10
10
now . getDate ( ) - now . getDay ( ) - 1 ,
11
11
)
12
- expect ( createDisplayDate ( date ) ) . toEqual ( "last Saturday" )
12
+ expect ( createDisplayDate ( date , now ) ) . toEqual ( "last Saturday" )
13
13
} )
14
14
} )
Original file line number Diff line number Diff line change @@ -10,8 +10,8 @@ export interface TimelineDateRow {
10
10
11
11
// We only want the message related to the date since the time is displayed
12
12
// inside of the build row
13
- export const createDisplayDate = ( date : Date ) : string =>
14
- formatRelative ( date , new Date ( ) ) . split ( " at " ) [ 0 ]
13
+ export const createDisplayDate = ( date : Date , base = new Date ( ) ) : string =>
14
+ formatRelative ( date , base ) . split ( " at " ) [ 0 ]
15
15
16
16
export const TimelineDateRow : FC < TimelineDateRow > = ( { date } ) => {
17
17
const styles = useStyles ( )
You can’t perform that action at this time.
0 commit comments