Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
cpcramer committed Mar 10, 2025
1 parent 8709a40 commit 6e2360d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/identity/hooks/useAvatars.test.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/identity/hooks/useNames.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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',
Expand Down
30 changes: 18 additions & 12 deletions src/identity/utils/getAvatars.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

Expand Down Expand Up @@ -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);
});

Expand Down
8 changes: 5 additions & 3 deletions src/identity/utils/getNames.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {});
Expand Down

0 comments on commit 6e2360d

Please sign in to comment.