Skip to content

Commit

Permalink
Use correct, custom formatter in Age component
Browse files Browse the repository at this point in the history
  • Loading branch information
buberdds committed Feb 5, 2024
1 parent 9953833 commit be6e7ec
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions .changelog/1230.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use correct, custom formatter in Age component
20 changes: 20 additions & 0 deletions src/app/components/Age/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { screen } from '@testing-library/react'
import { renderWithProviders } from '../../../utils/renderWithProviders'
import { Age } from '../'

describe('RuntimeBlockDetailView', () => {
beforeEach(() => {
jest.useFakeTimers()
jest.setSystemTime(new Date('2024-02-05T10:14:35.000Z'))
})

afterEach(() => {
jest.useRealTimers()
})

it('should display formatted values', () => {
renderWithProviders(<Age sinceTimestamp={'2024-02-05T10:14:40.000Z'} />)
expect(screen.getByText('5 sec')).toBeInTheDocument()
expect(screen.queryByText('less than a minute')).not.toBeInTheDocument()
})
})
2 changes: 1 addition & 1 deletion src/app/components/Age/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { FC } from 'react'
import Tooltip from '@mui/material/Tooltip'
import { formatDistanceToNow } from 'date-fns'
import { formatDistanceToNow } from '../../utils/dateFormatter'
import Box from '@mui/material/Box'
import { useFormattedTimestamp } from '../../hooks/useFormattedTimestamp'
import { tooltipDelay } from '../../../styles/theme'
Expand Down

0 comments on commit be6e7ec

Please sign in to comment.