forked from binary-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Suisin/chore: test case for jurisdiction card section #57
Merged
matin-deriv
merged 4 commits into
amina-deriv:amina/feature/90115/update_jurisdiction
from
suisin-deriv:suisin/93478/test_case_for_jurisdiction_card_section
Apr 27, 2023
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
5183e24
chore: test case for jurisdiction card section
suisin-deriv 48ee27b
Merge branch 'amina/feature/90115/update_jurisdiction' of github.com:…
suisin-deriv 4dc36fa
chore: update test case based on latest update
suisin-deriv ae2b971
chore: remove as const from code
suisin-deriv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
126 changes: 126 additions & 0 deletions
126
packages/cfd/src/Containers/jurisdiction-modal/__test__/jurisdiction-card-section.spec.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 |
---|---|---|
@@ -0,0 +1,126 @@ | ||
import React from 'react'; | ||
import { screen, render } from '@testing-library/react'; | ||
import JurisdictionCardSection from '../jurisdiction-card-section'; | ||
import { Jurisdiction } from '@deriv/shared'; | ||
|
||
describe('JurisdictionCardSection', () => { | ||
type TMockProps = { | ||
account_status: { | ||
authentication: { | ||
document: { | ||
status: 'none' | 'pending' | 'verified' | 'expired' | 'rejected' | undefined; | ||
}; | ||
identity: { | ||
services: { | ||
idv: { | ||
status: 'none' | 'pending' | 'verified' | 'expired' | 'rejected' | undefined; | ||
}; | ||
onfido: { | ||
status: 'none' | 'pending' | 'verified' | 'expired' | 'rejected' | undefined; | ||
}; | ||
manual: { | ||
status: 'none' | 'pending' | 'verified' | 'expired' | 'rejected' | undefined; | ||
}; | ||
}; | ||
}; | ||
needs_verification: string[]; | ||
}; | ||
currency_config: { | ||
[k: string]: { | ||
is_deposit_suspended?: 0 | 1; | ||
is_withdrawal_suspended?: 0 | 1; | ||
}; | ||
}; | ||
p2p_status: 'none'; | ||
prompt_client_to_authenticate: 0; | ||
risk_classification: string; | ||
status: string[]; | ||
}; | ||
card_section_item: { | ||
key: string; | ||
title: string; | ||
title_indicators?: { | ||
type: 'displayText'; | ||
display_text: string; | ||
display_text_skin_color: string; | ||
}; | ||
description?: string; | ||
clickable_description?: [{ type: 'link' | 'text'; text: string }]; | ||
}; | ||
type_of_card: 'svg' | 'bvi' | 'vanuatu' | 'labuan' | 'maltainvest'; | ||
toggleCardFlip: jest.Mock; | ||
verification_docs: ['document_number' | 'selfie' | 'identity_document' | 'name_and_address' | 'not_applicable']; | ||
}; | ||
const mock_props: TMockProps = { | ||
account_status: { | ||
authentication: { | ||
document: { | ||
status: 'none', | ||
}, | ||
identity: { | ||
services: { | ||
idv: { | ||
status: 'none', | ||
}, | ||
onfido: { | ||
status: 'none', | ||
}, | ||
manual: { | ||
status: 'none', | ||
}, | ||
}, | ||
}, | ||
needs_verification: [], | ||
}, | ||
currency_config: {}, | ||
p2p_status: 'none', | ||
prompt_client_to_authenticate: 0, | ||
risk_classification: '', | ||
status: [''], | ||
}, | ||
card_section_item: { | ||
key: '', | ||
title: 'Test Title', | ||
title_indicators: { | ||
type: 'displayText', | ||
display_text: 'Test Title Indicators Text', | ||
display_text_skin_color: '', | ||
}, | ||
description: 'Test Description', | ||
}, | ||
type_of_card: Jurisdiction.SVG, | ||
toggleCardFlip: jest.fn(), | ||
verification_docs: ['not_applicable'], | ||
}; | ||
|
||
it('should render JurisdictionCardSection component', () => { | ||
render(<JurisdictionCardSection {...mock_props} />); | ||
expect(screen.getByText('Test Title')).toBeInTheDocument(); | ||
expect(screen.getByText('Test Title Indicators Text')).toBeInTheDocument(); | ||
expect(screen.getByText('Test Description')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render JurisdictionCardSection component with clickable description', () => { | ||
const mock_props_with_clickable_description = { | ||
...mock_props, | ||
card_section_item: { | ||
...mock_props.card_section_item, | ||
clickable_description: [{ type: 'link' as const, text: 'Test Link' }], | ||
}, | ||
}; | ||
|
||
render(<JurisdictionCardSection {...mock_props_with_clickable_description} />); | ||
expect(screen.getByText('Test Title')).toBeInTheDocument(); | ||
expect(screen.getByText('Test Title Indicators Text')).toBeInTheDocument(); | ||
expect(screen.getByText('Test Link')).toBeInTheDocument(); | ||
expect(screen.queryByText('Test Description')).not.toBeInTheDocument(); | ||
}); | ||
|
||
it('should render JurisdictionCardSection component without displaying title indicators if it is empty', () => { | ||
mock_props.card_section_item.title_indicators = undefined; | ||
render(<JurisdictionCardSection {...mock_props} />); | ||
expect(screen.getByText('Test Title')).toBeInTheDocument(); | ||
expect(screen.queryByText('Test Title Indicators Text')).not.toBeInTheDocument(); | ||
expect(screen.getByText('Test Description')).toBeInTheDocument(); | ||
}); | ||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we remove this
'as'
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried removing
as const
from this but it seems like Typescript is giving me error stating that it will be read as string instead of 'link'There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will it work if we explicitly create a type for
mock_props_with_clickable_description
and feed the values to it?like
mock_props_with_clickable_description:Ttype = {values}
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried that but it doesn't work either 😓
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you may please check with matin. rest LGTM 😃 👍