Fix relative date test that will fail across months

This commit is contained in:
shamoon 2024-04-30 22:06:19 -07:00
parent 8b4fc02955
commit 8d516c08f0

View File

@ -33,8 +33,9 @@ describe('CustomDatePipe', () => {
const notNow = new Date(now) const notNow = new Date(now)
notNow.setDate(now.getDate() - 1) notNow.setDate(now.getDate() - 1)
expect(datePipe.transform(notNow, 'relative')).toEqual('1 day ago') expect(datePipe.transform(notNow, 'relative')).toEqual('1 day ago')
notNow.setDate(now.getDate() - 2) notNow.setDate(now.getDate())
expect(datePipe.transform(notNow, 'relative')).toEqual('2 days ago') notNow.setMonth(now.getMonth() - 1)
expect(datePipe.transform(notNow, 'relative')).toEqual('1 month ago')
expect(datePipe.transform(now, 'relative')).toEqual('Just now') expect(datePipe.transform(now, 'relative')).toEqual('Just now')
}) })
}) })