Skip to content

Commit

Permalink
added tests for content hash display on ProfileDetails
Browse files Browse the repository at this point in the history
  • Loading branch information
storywithoutend committed Aug 28, 2023
1 parent bacb891 commit a709d3e
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/components/pages/profile/ProfileDetails.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ import { OwnerArray } from '@app/types'

import { ownershipInfoCalc } from './ProfileDetails'

import { ProfileDetails } from './ProfileDetails'
import { render, screen } from '@app/test-utils'

jest.mock('@app/utils/BreakpointProvider', () => ({
useBreakpoint: () => ({
xs: true,
sm: true,
md: true,
lg: true,
xl: false,
})
}))

describe('onwershipInfoCalc', () => {
it('should return no owner if PCC is expired', () => {
const result = ownershipInfoCalc('', true, [], new Date(), new Date())
Expand Down Expand Up @@ -95,3 +108,16 @@ describe('onwershipInfoCalc', () => {
])
})
})

describe('ProfileDetails', () => {
it('should show content hash if there is valid contenthash', () => {
render(<ProfileDetails name="test.eth" expiryDate={undefined} textRecords={[]} addresses={[]} pccExpired={false} owners={[]} actions={[]} contentHash="ipfs://QmXoypizjW3WknFiJnKLwHCnL72vedxjQkDDP1mXWo6uco" />)
expect(screen.getByTestId('other-profile-button-contenthash')).toBeVisible()
expect(screen.getByText('ipfs://QmXoypiz...')).toBeVisible()
})

it('should not show content hash if contenthash is empty', () => {
render(<ProfileDetails name="test.eth" expiryDate={undefined} textRecords={[]} addresses={[]} pccExpired={false} owners={[]} actions={[]} contentHash={{}} />)
expect(screen.queryByTestId('other-profile-button-contenthash')).toBeNull()
})
})

0 comments on commit a709d3e

Please sign in to comment.