Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
katspaugh committed Feb 15, 2024
1 parent 8020fcc commit d187363
Showing 1 changed file with 7 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,51 +1,24 @@
import * as nextRouter from 'next/router'
import * as nextNav from 'next/navigation'
import useChainId from '@/hooks/useChainId'
import { render, waitFor } from '@/tests/test-utils'
import { SafeAppAccessPolicyTypes } from '@safe-global/safe-gateway-typescript-sdk'
import SafeTokenWidget from '..'
import { toBeHex } from 'ethers'
import { AppRoutes } from '@/config/routes'
import useSafeTokenAllocation, { useSafeVotingPower } from '@/hooks/useSafeTokenAllocation'

const MOCK_GOVERNANCE_APP_URL = 'https://mock.governance.safe.global'

jest.mock('@/hooks/useChainId', () => jest.fn(() => '1'))

jest.mock('@/hooks/useSafeTokenAllocation')

jest.mock(
'@/hooks/safe-apps/useRemoteSafeApps',
jest.fn(() => ({
useRemoteSafeApps: () => [
[
{
id: 61,
url: MOCK_GOVERNANCE_APP_URL,
chainIds: ['4'],
name: 'Safe {DAO} Governance',
description: '',
iconUrl: '',
tags: ['safe-dao-governance-app'],
accessControl: {
type: SafeAppAccessPolicyTypes.NoRestrictions,
},
},
],
],
})),
)

describe('SafeTokenWidget', () => {
const fakeSafeAddress = toBeHex('0x1', 20)
beforeEach(() => {
jest.restoreAllMocks()
jest.spyOn(nextRouter, 'useRouter').mockImplementation(
jest.spyOn(nextNav, 'useSearchParams').mockImplementation(
() =>
({
query: {
safe: fakeSafeAddress,
},
} as any),
get: () => fakeSafeAddress,
}) as any,

Check failure on line 21 in src/components/common/SafeTokenWidget/__tests__/SafeTokenWidget.test.tsx

View workflow job for this annotation

GitHub Actions / ESLint Results

prettier/prettier

Replace `)·as·any` with `·as·any)`
)
})

Expand Down Expand Up @@ -90,7 +63,9 @@ describe('SafeTokenWidget', () => {
const result = render(<SafeTokenWidget />)
await waitFor(() => {
expect(result.baseElement).toContainHTML(
`href="${AppRoutes.apps.open}?safe=${fakeSafeAddress}&appUrl=${encodeURIComponent(MOCK_GOVERNANCE_APP_URL)}"`,
`href="${AppRoutes.apps.open}?safe=${fakeSafeAddress}&appUrl=${encodeURIComponent(
'https://safe-dao-governance.dev.5afe.dev',
)}`,
)
})
})
Expand Down

0 comments on commit d187363

Please sign in to comment.