Skip to content

Commit

Permalink
liting
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcramer committed Mar 10, 2025
1 parent 328649e commit d26902b
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions src/identity/hooks/useAvatars.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { publicClient } from '@/core/network/client';
import { getChainPublicClient } from '@/core/network/getChainPublicClient';
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';
Expand Down Expand Up @@ -241,8 +240,10 @@ describe('useAvatars', () => {
const testEnsNames = ['success1.eth', 'fail.eth', 'success2.eth'];

const partialResults = ['avatar1-url', null, 'avatar2-url'];
const mockGetAvatars = vi.spyOn({ getAvatars }, 'getAvatars');
mockGetAvatars.mockResolvedValue(partialResults);
mockGetEnsAvatar
.mockResolvedValueOnce('avatar1-url')
.mockRejectedValueOnce(new Error('Failed to resolve avatar'))
.mockResolvedValueOnce('avatar2-url');

const { result } = renderHook(
() => useAvatars({ ensNames: testEnsNames }),
Expand All @@ -257,11 +258,6 @@ describe('useAvatars', () => {
expect(result.current.isError).toBe(false);
});

expect(mockGetAvatars).toHaveBeenCalledWith({
ensNames: testEnsNames,
chain: mainnet,
});

mockGetAvatars.mockRestore();
expect(getChainPublicClient).toHaveBeenCalledWith(mainnet);
});
});

0 comments on commit d26902b

Please sign in to comment.