Skip to content

Commit

Permalink
adding unit test for invalid tab should redirect to profile tab
Browse files Browse the repository at this point in the history
  • Loading branch information
vuongnmdevblock committed Sep 4, 2024
1 parent 9dacb79 commit d82c343
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/utils/shouldRedirect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ describe('shouldRedirect', () => {
isSelf: false,
decodedName,
normalisedName,
visibileTabs: ['profile', 'records', 'ownership', 'subnames', 'more'],
tab: 'profile',
}
shouldRedirect(mockRouter as never, 'Profile.tsx', '/profile', params)
expect(mockRouter.pathname).toBe(`/profile/${decodedName}`)
Expand All @@ -121,6 +123,8 @@ describe('shouldRedirect', () => {
isSelf: false,
decodedName,
normalisedName,
visibileTabs: ['profile', 'records', 'ownership', 'subnames', 'more'],
tab: 'profile',
}
shouldRedirect(mockRouter as never, 'Profile.tsx', '/profile', params)
expect(mockRouter.pathname).toBe(`/profile/${normalisedName}`)
Expand All @@ -136,6 +140,25 @@ describe('shouldRedirect', () => {
isSelf: true,
decodedName,
normalisedName,
visibileTabs: ['profile', 'records', 'ownership', 'subnames', 'more'],
tab: 'profile',
}
shouldRedirect(mockRouter as never, 'Profile.tsx', '/profile', params)
expect(mockRouter.pathname).toBe(`/profile/${name}`)
})

it('Profile.tsx should "/profile/[name]" expected path if invalid tab', () => {
const name = 'test'
const decodedName = 'test.eth'
const normalisedName =
'[fa1ea47215815692a5f1391cff19abbaf694c82fb2151a4c351b6c0eeaaf317b].test.eth'
const params = {
name,
isSelf: true,
decodedName,
normalisedName,
visibileTabs: ['profile', 'records', 'ownership', 'subnames', 'more'],
tab: 'custom',
}
shouldRedirect(mockRouter as never, 'Profile.tsx', '/profile', params)
expect(mockRouter.pathname).toBe(`/profile/${name}`)
Expand Down

0 comments on commit d82c343

Please sign in to comment.