From d187363772efa367ef1b17b8d4805c18d267bda5 Mon Sep 17 00:00:00 2001 From: katspaugh Date: Thu, 15 Feb 2024 14:06:41 +0100 Subject: [PATCH] Fix tests --- .../__tests__/SafeTokenWidget.test.tsx | 39 ++++--------------- 1 file changed, 7 insertions(+), 32 deletions(-) diff --git a/src/components/common/SafeTokenWidget/__tests__/SafeTokenWidget.test.tsx b/src/components/common/SafeTokenWidget/__tests__/SafeTokenWidget.test.tsx index 04d4c189e0..af86274b46 100644 --- a/src/components/common/SafeTokenWidget/__tests__/SafeTokenWidget.test.tsx +++ b/src/components/common/SafeTokenWidget/__tests__/SafeTokenWidget.test.tsx @@ -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, ) }) @@ -90,7 +63,9 @@ describe('SafeTokenWidget', () => { const result = render() 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', + )}`, ) }) })