Skip to content

Commit

Permalink
Merge pull request #870 from ensdomains/FET-1618-test
Browse files Browse the repository at this point in the history
Fet 1618 test
  • Loading branch information
LeonmanRolls committed Sep 12, 2024
2 parents 727b4f9 + eadf20b commit 165b7ff
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
19 changes: 19 additions & 0 deletions src/components/@atoms/ErrorScreen.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { render, screen } from '@app/test-utils'

import { describe, expect, it, vi } from 'vitest'

import ErrorScreen from './ErrorScreen'

describe('ErrorScreen', () => {
it('renders not-found error correctly', () => {
render(<ErrorScreen errorType="not-found" />)
expect(screen.findAllByText('Not found')).toBeTruthy()
expect(screen.getByTestId('question-circle-svg')).toBeVisible()
})

it('renders application-error correctly', () => {
render(<ErrorScreen errorType="application-error" />)
expect(screen.findAllByText('Application error')).toBeTruthy()
expect(screen.getByTestId('alert-svg')).toBeVisible()
})
})
6 changes: 5 additions & 1 deletion src/components/@atoms/ErrorScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ const ErrorScreen = ({ errorType }: { errorType: ErrorType }) => {

return (
<Container className={errorType}>
{errorType === 'not-found' ? <QuestionCircleSVG /> : <AlertSVG />}
{errorType === 'not-found' ? (
<QuestionCircleSVG data-testid="question-circle-svg" />
) : (
<AlertSVG data-testid="alert-svg" />
)}
<Typography fontVariant="headingOne">{t('title')}</Typography>
<Typography fontVariant="body">
<Trans
Expand Down
1 change: 1 addition & 0 deletions src/test-utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ vi.mock('react-i18next', () => ({
i18n: {
isInitialized: true,
},
ready: true,
}),
Trans: ({ i18nKey, values }: { i18nKey: string; values: string[] }) =>
`${i18nKey} ${values ? Object.values(values).join(', ') : ''}`,
Expand Down

0 comments on commit 165b7ff

Please sign in to comment.