-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Stanislav Lysak
committed
Sep 3, 2024
1 parent
d2fc9d6
commit 2f27848
Showing
3 changed files
with
55 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 46 additions & 31 deletions
77
src/components/pages/profile/[name]/ProfileEmptyBanner.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,68 @@ | ||
import { render, screen } from '@app/test-utils' | ||
import { mockFunction, render, screen } from '@app/test-utils' | ||
|
||
import { describe, expect, it, vi } from 'vitest' | ||
|
||
import { AddressRecord } from '@app/types' | ||
import { useProfile } from '@app/hooks/useProfile' | ||
|
||
import { ProfileEmptyBanner } from './ProfileEmptyBanner' | ||
|
||
vi.mock('@app/hooks/abilities/useAbilities', () => ({ | ||
useAbilities: () => ({ | ||
data: { | ||
canSendOwner: true, | ||
canSendManager: true, | ||
canEditRecords: true, | ||
sendNameFunctionCallDetails: { | ||
sendManager: { | ||
contract: 'contract', | ||
}, | ||
sendOwner: { | ||
contract: 'contract', | ||
}, | ||
}, | ||
}, | ||
isLoading: false, | ||
}), | ||
})) | ||
vi.mock('@app/hooks/useProtectedRoute', () => ({ | ||
useProtectedRoute: vi.fn(), | ||
})) | ||
vi.mock('@app/utils/BreakpointProvider') | ||
vi.mock('next/router', async () => await vi.importActual('next-router-mock')) | ||
vi.mock('@app/hooks/useProfile') | ||
|
||
const mockUseProfile = mockFunction(useProfile) | ||
|
||
describe('ProfileEmptyBanner', () => { | ||
it('should not display banner if have addresses', () => { | ||
it('should not display banner if have records', () => { | ||
const name = 'test' | ||
const addresses: AddressRecord[] = [ | ||
{ | ||
id: 1, | ||
name: 'ADR1', | ||
value: 'addr1-value', | ||
|
||
mockUseProfile.mockImplementation(() => ({ | ||
data: { | ||
texts: [ | ||
{ | ||
key: 'avatar', | ||
value: 'http://localhost:3000', | ||
}, | ||
], | ||
coins: [ | ||
{ | ||
id: 60, | ||
name: 'eth', | ||
value: '0x8327FcD61f5e90e1E05A3F49DCbc9346b7d111111', | ||
}, | ||
], | ||
contentHash: null, | ||
abi: null, | ||
resolverAddress: '0x8327FcD61f5e90e1E05A3F49DCbc9346b7d111112', | ||
isMigrated: true, | ||
createdAt: { | ||
date: '2024-08-02T10:33:00.000Z', | ||
value: 1722594780000, | ||
}, | ||
address: '0x8327FcD61f5e90e1E05A3F49DCbc9346b7d175f7', | ||
}, | ||
] | ||
render(<ProfileEmptyBanner name={name} addresses={addresses} />) | ||
isLoading: false, | ||
})) | ||
|
||
render(<ProfileEmptyBanner name={name} />) | ||
expect(screen.queryByTestId('profile-empty-banner')).not.toBeInTheDocument() | ||
}) | ||
it('should display banner if have no addresses', () => { | ||
|
||
it('should display banner if have no records', () => { | ||
const name = 'test' | ||
const addresses: AddressRecord[] = [] | ||
|
||
render(<ProfileEmptyBanner name={name} addresses={addresses} />) | ||
mockUseProfile.mockImplementation(() => ({ | ||
data: { | ||
text: [], | ||
coins: [], | ||
}, | ||
isLoading: false, | ||
})) | ||
|
||
render(<ProfileEmptyBanner name={name} />) | ||
expect(screen.queryByTestId('profile-empty-banner')).toBeInTheDocument() | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters