-
Notifications
You must be signed in to change notification settings - Fork 394
[WALL] Lubega / WALL-3305 / IDVDocumentUploadDetails unit test and isDetailsVerified checkbox #12957
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
Merged
nijil-deriv
merged 6 commits into
deriv-com:master
from
lubega-deriv:WALL-3305/idv-document-upload-details-checkbox
Jan 17, 2024
Merged
[WALL] Lubega / WALL-3305 / IDVDocumentUploadDetails unit test and isDetailsVerified checkbox #12957
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
c6eec76
feat: idv document upload details checkbox and unit test
lubega-deriv f729ea1
fix: updated unit test
lubega-deriv d270690
Merge branch 'master' of github.com:binary-com/deriv-app into WALL-33…
lubega-deriv f6675d8
fix: updated implementation of isDetailsVerified
lubega-deriv 77f59e3
fix: updated implementation to incorporate formik logic
lubega-deriv 7ca85a3
fix: failed test
lubega-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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
113 changes: 113 additions & 0 deletions
113
...entUpload/components/IDVDocumentUploadDetails/__tests__/IDVDocumentUploadDetails.spec.tsx
This file contains hidden or 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,113 @@ | ||
| import React from 'react'; | ||
| import moment from 'moment'; | ||
| import { useSettings } from '@deriv/api'; | ||
| import { fireEvent, render, screen } from '@testing-library/react'; | ||
| import { FlowProvider, FlowTextField } from '../../../../../../../components'; | ||
| import IDVDocumentUploadDetails from '../IDVDocumentUploadDetails'; | ||
|
|
||
| jest.mock('@deriv/api', () => ({ | ||
| useSettings: jest.fn(), | ||
| })); | ||
|
|
||
| describe('IDVDocumentUploadDetails', () => { | ||
| beforeEach(() => { | ||
| (useSettings as jest.Mock).mockReturnValue({ | ||
| data: { | ||
| date_of_birth: 0, | ||
| first_name: 'John', | ||
| last_name: 'Doe', | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| test('should render component with default values', () => { | ||
| render( | ||
| <FlowProvider | ||
| initialValues={{ | ||
| test: 'default', | ||
| }} | ||
| screens={{ | ||
| test: <FlowTextField name='test' />, | ||
| }} | ||
| > | ||
| {() => { | ||
| return <IDVDocumentUploadDetails />; | ||
| }} | ||
| </FlowProvider> | ||
| ); | ||
|
|
||
| expect(screen.getByLabelText('First name*')).toHaveValue('John'); | ||
| expect(screen.getByLabelText('Last name*')).toHaveValue('Doe'); | ||
| expect(screen.getByLabelText('Date of birth*')).toHaveValue('1970-01-01'); | ||
| expect( | ||
| screen.getByLabelText(/I confirm that the name and date of birth above match my chosen identity document/) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('should render component with date of birth if existing in getSettings', () => { | ||
| (useSettings as jest.Mock).mockReturnValue({ | ||
| data: { | ||
| date_of_birth: moment().subtract(25, 'years').unix(), | ||
| first_name: 'John', | ||
| last_name: 'Doe', | ||
| }, | ||
| }); | ||
|
|
||
| render( | ||
| <FlowProvider | ||
| initialValues={{ | ||
| test: 'default', | ||
| }} | ||
| screens={{ | ||
| test: <FlowTextField name='test' />, | ||
| }} | ||
| > | ||
| {() => { | ||
| return <IDVDocumentUploadDetails />; | ||
| }} | ||
| </FlowProvider> | ||
| ); | ||
|
|
||
| expect(screen.getByLabelText('First name*')).toHaveValue('John'); | ||
| expect(screen.getByLabelText('Last name*')).toHaveValue('Doe'); | ||
| expect(screen.getByLabelText('Date of birth*')).toHaveValue( | ||
| moment().subtract(25, 'years').format('YYYY-MM-DD') | ||
| ); | ||
| expect( | ||
| screen.getByLabelText(/I confirm that the name and date of birth above match my chosen identity document/) | ||
| ).toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('should handle checkbox and fields change correctly when checkbox is checked', () => { | ||
| render( | ||
| <FlowProvider | ||
| initialValues={{ | ||
| test: 'default', | ||
| }} | ||
| screens={{ | ||
| test: <FlowTextField name='test' />, | ||
| }} | ||
| > | ||
| {() => { | ||
| return <IDVDocumentUploadDetails />; | ||
| }} | ||
| </FlowProvider> | ||
| ); | ||
|
|
||
| fireEvent.click( | ||
| screen.getByLabelText(/I confirm that the name and date of birth above match my chosen identity document/) | ||
| ); | ||
|
|
||
| expect(screen.getByLabelText('First name*')).toBeDisabled(); | ||
| expect(screen.getByLabelText('Last name*')).toBeDisabled(); | ||
| expect(screen.getByLabelText('Date of birth*')).toBeDisabled(); | ||
|
|
||
| fireEvent.click( | ||
| screen.getByLabelText(/I confirm that the name and date of birth above match my chosen identity document/) | ||
| ); | ||
|
|
||
| expect(screen.getByLabelText('First name*')).toBeEnabled(); | ||
| expect(screen.getByLabelText('Last name*')).toBeEnabled(); | ||
| expect(screen.getByLabelText('Date of birth*')).toBeEnabled(); | ||
| }); | ||
| }); |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.