forked from binary-com/deriv-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: 🎨 migrated component to TSX (#48) (binary-com#10116)
* refactor: 🎨 migrated component to TSX (#48) * refactor: 🎨 migrated component to TSX * refactor: ⚰️ unused import * fix: 🎨 migrated config to tsx (#49) * refactor: migrated components to tsx * refactor: migrated components to tsx * chore: added testcases * chore: added testcases * Merge branch 'master' into sprint-10/account-package-refactor * fix: 🧪 fixed failing testcase * fix: 🧪 fixed failing testcase * Likhith/migrate poo form (#50) * refactor: removed dead code * chore: fixed error condition * chore: update from master * fix: error object props * chore: poo ts init (#53) * chore: poo ts init * chore: remove query * chore: some types fix * chore: revert observer for poo form --------- Co-authored-by: “yauheni-kryzhyk-deriv” <“yauheni@deriv.me”> * feat: refactored POO form values * fix: Error text for Failure of IDV * fix: file upload * fix: POO validation * fix: failing testcase * fix: added validations * fix: types of payment method * fix: testcases for POO * fix: code smells * fix: resolved code smells * refactor: types errors (#58) Co-authored-by: “yauheni-kryzhyk-deriv” <“yauheni@deriv.me”> * fix: resolved code smells * fix: code smells * fix: async behavior * fix: import constant * fix: rename Const * refactor: sonarcloud issues * fix: incorporated review comments * fix: Convert the conditional to a boolean to avoid leaked value * fix: incorporated review comments * refactor: incorporated review comments * fix: removed duplicate status * chore: poo-form review comments * fix: code smells * fix: failing testcase * fix: wrong upload settings field name * chore: unused import remove * fix: duplicate filling of payment-method * fix: removed unused import * fix:reset form * fix: resolved error display bugs * Merge branch 'master' into sprint-10/account-package-refactor * fix: issue related with POO disble * fix: code smells * fix: code smells * refactor: incorporated review comments * fix: removed prop drilling * fix: incorporated useFileUploader hook * refactor: removed hook implementation * fix: resolved loading and validation * fix: incorrect status display issue * chore: removed console statements * fix: reinitialize form on value change --------- Co-authored-by: “yauheni-kryzhyk-deriv” <“yauheni@deriv.me”> Co-authored-by: yauheni-deriv <103182683+yauheni-deriv@users.noreply.github.com>
- Loading branch information
1 parent
6a2c14c
commit 7bc8fdc
Showing
46 changed files
with
1,295 additions
and
1,096 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
36 changes: 36 additions & 0 deletions
36
...count/src/Components/sample-credit-card-modal/__tests__/sample-credit-card-modal.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,36 @@ | ||
import React from 'react'; | ||
import { screen, render } from '@testing-library/react'; | ||
import { SampleCreditCardModal } from '../sample-credit-card-modal'; | ||
|
||
describe('SampleCreditCardModal', () => { | ||
let modal_root_el: HTMLDivElement; | ||
beforeAll(() => { | ||
modal_root_el = document.createElement('div'); | ||
modal_root_el.setAttribute('id', 'modal_root'); | ||
document.body.appendChild(modal_root_el); | ||
}); | ||
|
||
afterAll(() => { | ||
document.body.removeChild(modal_root_el); | ||
}); | ||
|
||
it('should render modal props', () => { | ||
const props: React.ComponentProps<typeof SampleCreditCardModal> = { | ||
is_open: true, | ||
onClose: jest.fn(), | ||
}; | ||
render(<SampleCreditCardModal {...props} />); | ||
expect(screen.getByRole('heading')).toHaveTextContent('How to mask your card?'); | ||
expect(screen.getByRole('img')).toHaveAttribute('alt', 'creditcardsample'); | ||
}); | ||
|
||
it('should not render modal when is_open is false', () => { | ||
const props: React.ComponentProps<typeof SampleCreditCardModal> = { | ||
is_open: false, | ||
onClose: jest.fn(), | ||
}; | ||
render(<SampleCreditCardModal {...props} />); | ||
expect(screen.queryByRole('heading')).not.toBeInTheDocument(); | ||
expect(screen.queryByRole('img')).not.toBeInTheDocument(); | ||
}); | ||
}); |
2 changes: 1 addition & 1 deletion
2
...ponents/sample-credit-card-modal/index.js → ...ponents/sample-credit-card-modal/index.ts
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,3 +1,3 @@ | ||
import { SampleCreditCardModal } from './sample-credit-card-modal.jsx'; | ||
import { SampleCreditCardModal } from './sample-credit-card-modal'; | ||
|
||
export default SampleCreditCardModal; |
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
File renamed without changes.
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
This file was deleted.
Oops, something went wrong.
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,16 @@ | ||
export const IDENTIFIER_TYPES = Object.freeze({ | ||
ACCOUNT_ID: 'account_id', | ||
ACCOUNT_NUMBER: 'account_number', | ||
BANK_ACCOUNT_NUMBER: 'bank_account_number', | ||
CARD_NUMBER: 'card_number', | ||
EMAIL_ADDRESS: 'email_address', | ||
MOBILE_NUMBER: 'mobile_number', | ||
USER_ID: 'user_id', | ||
}); | ||
|
||
export const CARD_NUMBER = { | ||
MAX_LENGTH: 19, | ||
MIN_LENGTH: 16, | ||
}; | ||
|
||
export const MAX_FILE_SIZE = 8000; // 8MB |
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
53 changes: 53 additions & 0 deletions
53
packages/account/src/Containers/proof-of-ownership/__tests__/card.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,53 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import userEvent from '@testing-library/user-event'; | ||
import Card from '../card'; | ||
|
||
jest.mock('../expanded-card', () => jest.fn(() => <div>Expanded Card</div>)); | ||
|
||
describe('Card', () => { | ||
const mock_props: React.ComponentProps<typeof Card> = { | ||
details: { | ||
icon: 'IcVisaLight', | ||
payment_method: 'visa', | ||
items: [ | ||
{ | ||
creation_time: '1699433416524', | ||
id: 4, | ||
payment_method: 'visa', | ||
documents_required: 1, | ||
}, | ||
], | ||
instructions: ['mock instruction 1', 'mock instruction 2'], | ||
input_label: 'Card number', | ||
identifier_type: 'card_number', | ||
is_generic_pm: false, | ||
documents_required: 1, | ||
}, | ||
index: 0, | ||
}; | ||
|
||
it('should render payment method card', () => { | ||
render(<Card {...mock_props} />); | ||
expect(screen.getByText('visa')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should render expanded card when clicked', () => { | ||
render(<Card {...mock_props} />); | ||
|
||
userEvent.click(screen.getByRole('button')); | ||
expect(screen.getByText('Expanded Card')).toBeInTheDocument(); | ||
}); | ||
|
||
it('should close the rendered expanded card when clicked', () => { | ||
render(<Card {...mock_props} />); | ||
|
||
userEvent.click(screen.getByRole('button')); | ||
|
||
expect(screen.getByText('Expanded Card')).toBeInTheDocument(); | ||
|
||
userEvent.click(screen.getByRole('button')); | ||
|
||
expect(screen.queryByText('Expanded Card')).not.toBeInTheDocument(); | ||
}); | ||
}); |
Oops, something went wrong.