Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Nov 1, 2023
1 parent 083934c commit 507a1c0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 53 deletions.
54 changes: 3 additions & 51 deletions src/components/settings/FallbackHandler/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { act, fireEvent, render, waitFor } from '@/tests/test-utils'
import { render, waitFor } from '@/tests/test-utils'

import * as useSafeInfoHook from '@/hooks/useSafeInfo'
import * as useTxBuilderHook from '@/hooks/safe-apps/useTxBuilderApp'
Expand Down Expand Up @@ -104,7 +104,7 @@ describe('FallbackHandler', () => {
})

describe('No Fallback Handler', () => {
it('should render the Fallback Handler and warning tooltip when no Fallback Handler is set', async () => {
it('should render a warning when no Fallback Handler is set', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(
() =>
({
Expand All @@ -117,21 +117,6 @@ describe('FallbackHandler', () => {

const fbHandler = render(<FallbackHandler />)

await waitFor(() => {
expect(fbHandler.getByText('No fallback handler set')).toBeDefined()
})

const icon = fbHandler.getByTestId('fallback-handler-warning')

await act(() => {
fireEvent(
icon,
new MouseEvent('mouseover', {
bubbles: true,
}),
)
})

await waitFor(() => {
expect(
fbHandler.queryByText(
Expand All @@ -157,17 +142,6 @@ describe('FallbackHandler', () => {

const fbHandler = render(<FallbackHandler />)

const icon = fbHandler.getByTestId('fallback-handler-warning')

await act(() => {
fireEvent(
icon,
new MouseEvent('mouseover', {
bubbles: true,
}),
)
})

await waitFor(() => {
expect(
fbHandler.queryByText(
Expand All @@ -180,7 +154,7 @@ describe('FallbackHandler', () => {
})

describe('Unofficial Fallback Handler', () => {
it('should render placeholder and warning tooltip when an unofficial Fallback Handler is set', async () => {
it('should render placeholder and warning when an unofficial Fallback Handler is set', async () => {
jest.spyOn(useSafeInfoHook, 'default').mockImplementation(
() =>
({
Expand All @@ -206,17 +180,6 @@ describe('FallbackHandler', () => {
expect(fbHandler.getByText('0x123')).toBeDefined()
})

const icon = fbHandler.getByTestId('fallback-handler-warning')

await act(() => {
fireEvent(
icon,
new MouseEvent('mouseover', {
bubbles: true,
}),
)
})

await waitFor(() => {
expect(fbHandler.queryByText(new RegExp('An unofficial fallback handler is currently set.')))
expect(fbHandler.queryByText('Transaction Builder')).toBeInTheDocument()
Expand All @@ -241,17 +204,6 @@ describe('FallbackHandler', () => {

const fbHandler = render(<FallbackHandler />)

const icon = fbHandler.getByTestId('fallback-handler-warning')

await act(() => {
fireEvent(
icon,
new MouseEvent('mouseover', {
bubbles: true,
}),
)
})

await waitFor(() => {
expect(fbHandler.queryByText(new RegExp('An unofficial fallback handler is currently set.')))
expect(fbHandler.queryByText('Transaction Builder')).not.toBeInTheDocument()
Expand Down
4 changes: 2 additions & 2 deletions src/components/settings/FallbackHandler/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const FallbackHandler = (): ReactElement | null => {
const isOfficial =
hasFallbackHandler && safe.fallbackHandler?.value === fallbackHandlerDeployment?.networkAddresses[safe.chainId]

const tooltip = !hasFallbackHandler ? (
const warning = !hasFallbackHandler ? (
<>
The {'Safe{Wallet}'} may not work correctly as no fallback handler is currently set.
{txBuilder && (
Expand Down Expand Up @@ -79,7 +79,7 @@ export const FallbackHandler = (): ReactElement | null => {
</Typography>

<Alert severity={!hasFallbackHandler ? 'warning' : isOfficial ? 'success' : 'info'} sx={{ mt: 2 }}>
{tooltip && <Typography mb={hasFallbackHandler ? 2 : 0}>{tooltip}</Typography>}
{warning && <Typography mb={hasFallbackHandler ? 2 : 0}>{warning}</Typography>}

{safe.fallbackHandler && (
<EthHashInfo
Expand Down

0 comments on commit 507a1c0

Please sign in to comment.