diff --git a/src/identity/hooks/useAvatars.test.tsx b/src/identity/hooks/useAvatars.test.tsx index 5d0deb8963..46eff771c5 100644 --- a/src/identity/hooks/useAvatars.test.tsx +++ b/src/identity/hooks/useAvatars.test.tsx @@ -1,6 +1,6 @@ import { publicClient } from '@/core/network/client'; import { getChainPublicClient } from '@/core/network/getChainPublicClient'; -import * as getAvatarsModule from '@/identity/utils/getAvatars'; +import { getAvatars } from '@/identity/utils/getAvatars'; import { renderHook, waitFor } from '@testing-library/react'; import { base, baseSepolia, mainnet, optimism } from 'viem/chains'; import { type Mock, beforeEach, describe, expect, it, vi } from 'vitest'; @@ -241,7 +241,7 @@ describe('useAvatars', () => { const testEnsNames = ['success1.eth', 'fail.eth', 'success2.eth']; const partialResults = ['avatar1-url', null, 'avatar2-url']; - const mockGetAvatars = vi.spyOn(getAvatarsModule, 'getAvatars'); + const mockGetAvatars = vi.spyOn({ getAvatars }, 'getAvatars'); mockGetAvatars.mockResolvedValue(partialResults); const { result } = renderHook( diff --git a/src/identity/hooks/useNames.test.tsx b/src/identity/hooks/useNames.test.tsx index 511bf568ea..f8796ff963 100644 --- a/src/identity/hooks/useNames.test.tsx +++ b/src/identity/hooks/useNames.test.tsx @@ -3,7 +3,7 @@ import { renderHook, waitFor } from '@testing-library/react'; import type { Address } from 'viem'; import { base, mainnet, optimism } from 'viem/chains'; import { beforeEach, describe, expect, it, vi } from 'vitest'; -import * as getNamesFunctions from '../utils/getNames'; +import { getNames } from '../utils/getNames'; import { getNewReactQueryTestProvider } from './getNewReactQueryTestProvider'; import { useNames } from './useNames'; @@ -14,7 +14,7 @@ vi.mock('@/core/network/getChainPublicClient', () => ({ })); describe('useNames', () => { - const mockGetNames = vi.spyOn(getNamesFunctions, 'getNames'); + const mockGetNames = vi.spyOn({ getNames }, 'getNames'); const testAddresses = [ '0x1234567890123456789012345678901234567890', '0x2345678901234567890123456789012345678901', diff --git a/src/identity/utils/getAvatars.test.tsx b/src/identity/utils/getAvatars.test.tsx index 09f7fd0040..f7c484cc59 100644 --- a/src/identity/utils/getAvatars.test.tsx +++ b/src/identity/utils/getAvatars.test.tsx @@ -261,11 +261,16 @@ describe('getAvatars', () => { return Promise.reject( new Error('Avatar resolution failed for this name'), ); - } else if (params.name === 'success1.eth') { + } + + if (params.name === 'success1.eth') { return Promise.resolve('avatar1-url'); - } else if (params.name === 'success2.eth') { + } + + if (params.name === 'success2.eth') { return Promise.resolve('avatar2-url'); } + return Promise.resolve(null); }); @@ -293,17 +298,18 @@ describe('getAvatars', () => { mockGetEnsAvatar.mockReset(); mockGetEnsAvatar.mockImplementation((params) => { - // Base resolution - if (params.universalResolverAddress) { - if (params.name === 'fail.base.eth') { - return Promise.reject(new Error('Base avatar resolution failed')); - } else if (params.name === 'success1.base.eth') { - return Promise.resolve('base-avatar1-url'); - } else if (params.name === 'success2.base.eth') { - return Promise.resolve('base-avatar2-url'); - } + if (params.name === 'fail.base.eth') { + return Promise.reject(new Error('Base avatar resolution failed')); } - // Mainnet fallback (shouldn't be called for successful Base resolutions) + + if (params.name === 'success1.base.eth') { + return Promise.resolve('base-avatar1-url'); + } + + if (params.name === 'success2.base.eth') { + return Promise.resolve('base-avatar2-url'); + } + return Promise.resolve(null); }); diff --git a/src/identity/utils/getNames.test.ts b/src/identity/utils/getNames.test.ts index bc6a432659..d724f8b21e 100644 --- a/src/identity/utils/getNames.test.ts +++ b/src/identity/utils/getNames.test.ts @@ -164,11 +164,13 @@ describe('getNames', () => { mockGetEnsName.mockImplementation((params) => { if (params.address === walletAddresses[0]) { return Promise.resolve('user1.eth'); - } else if (params.address === walletAddresses[1]) { + } + + if (params.address === walletAddresses[1]) { return Promise.reject(new Error('ENS resolution failed')); - } else { - return Promise.resolve('user3.eth'); } + + return Promise.resolve('user3.eth'); }); const consoleSpy = vi.spyOn(console, 'error').mockImplementation(() => {});