mars-v2-frontend/__tests__/components/CircularProgress.test.tsx

35 lines
1.0 KiB
TypeScript
Raw Normal View History

import { render } from '@testing-library/react'
import { CircularProgress } from 'components/CircularProgress'
2023-10-23 12:04:17 +00:00
import { LocalStorageKeys } from 'constants/localStorageKeys'
describe('<CircularProgress />', () => {
afterAll(() => {
2023-10-23 12:04:17 +00:00
localStorage.removeItem(LocalStorageKeys.REDUCE_MOTION)
})
it('should render', () => {
const { container } = render(<CircularProgress />)
expect(container).toBeInTheDocument()
})
it('should render `...` when animations disabled', () => {
2023-10-23 12:04:17 +00:00
localStorage.setItem(LocalStorageKeys.REDUCE_MOTION, 'true')
const { getByText } = render(<CircularProgress />)
const threeDots = getByText('...')
expect(threeDots).toBeInTheDocument()
})
it('should render the component with animation classes when animations enabled', () => {
2023-10-23 12:04:17 +00:00
localStorage.setItem(LocalStorageKeys.REDUCE_MOTION, 'false')
const { container } = render(<CircularProgress />)
const progressWithAnimations = container.querySelector('.animate-progress')
expect(progressWithAnimations).toBeInTheDocument()
})
})