Skip to content
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

Ameerul/ P2PS-1453 resolve eslint errors #69

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ describe('<BuySellModal />', () => {
fetchAdvertiserAdverts: jest.fn(),
is_buy_advert: true,
setFormErrorCode: jest.fn(),
unsubscribeAdvertInfo: jest.fn(),
},
floating_rate_store: {
setIsMarketRateChanged: jest.fn(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ describe('<BuySellModalTitle />', () => {

render(<BuySellModalTitle />);

expect(screen.getByTestId('dt-buy-sell-modal-back-icon')).toBeInTheDocument();
expect(screen.getByTestId('dt_buy_sell_modal_back_icon')).toBeInTheDocument();
expect(screen.getByText('Add payment method')).toBeInTheDocument();
});

it('should call setShouldShowAddPaymentMethodForm when clicking the icon, if is_form_modified is false', () => {
render(<BuySellModalTitle />);

const back_icon = screen.getByTestId('dt-buy-sell-modal-back-icon');
const back_icon = screen.getByTestId('dt_buy_sell_modal_back_icon');
userEvent.click(back_icon);

expect(mock_store.my_profile_store.setShouldShowAddPaymentMethodForm).toHaveBeenCalledWith(false);
Expand All @@ -87,7 +87,7 @@ describe('<BuySellModalTitle />', () => {

render(<BuySellModalTitle />);

const back_icon = screen.getByTestId('dt-buy-sell-modal-back-icon');
const back_icon = screen.getByTestId('dt_buy_sell_modal_back_icon');
userEvent.click(back_icon);

expect(mock_modal_manager.showModal).toHaveBeenCalledWith({ key: 'CancelAddPaymentMethodModal', props: {} });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.buy-sell-modal-title {
display: flex;
align-items: center;

&__icon {
margin-right: 0.8rem;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import React from 'react';
import { Icon, Text } from '@deriv/components';
import { observer } from '@deriv/stores';
import { isDesktop } from '@deriv/shared';
import { useStores } from 'Stores';
import { Localize } from 'Components/i18next';
import { useModalManagerContext } from 'Components/modal-manager/modal-manager-context';
import { buy_sell } from 'Constants/buy-sell';
import { useStores } from 'Stores';

const BuySellModalTitle = () => {
const { general_store, buy_sell_store, advertiser_page_store, my_profile_store } = useStores();
Expand All @@ -18,16 +19,14 @@ const BuySellModalTitle = () => {
if (my_profile_store.should_show_add_payment_method_form) {
if (isDesktop()) {
return (
<React.Fragment>
<div className='buy-sell-modal-title'>
<Icon
icon='IcArrowLeftBold'
data_testid='dt-buy-sell-modal-back-icon'
data_testid='dt_buy_sell_modal_back_icon'
onClick={() => {
if (general_store.is_form_modified) {
showModal({
key: 'CancelAddPaymentMethodModal',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore TODO: fix typings in CancelAddPaymentMethodModal and make them optional and remove this comment
props: {},
});
} else {
Expand All @@ -37,7 +36,7 @@ const BuySellModalTitle = () => {
className='buy-sell-modal-title__icon'
/>
<Localize i18n_default_text='Add payment method' />
</React.Fragment>
</div>
);
}
return <Localize i18n_default_text='Add payment method' />;
Expand All @@ -49,10 +48,10 @@ const BuySellModalTitle = () => {
};

return (
<Text as='p' color='prominent' line_height='m' size='s' weight='bold'>
<Text as='p' color='prominent' weight='bold'>
{getModalTitle()}
</Text>
);
};

export default BuySellModalTitle;
export default observer(BuySellModalTitle);
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ const BuySellModal = () => {
if (general_store.is_form_modified) {
showModal({
key: 'CancelAddPaymentMethodModal',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore TODO: fix typings in CancelAddPaymentMethodModal and make them optional and remove this comment
props: {},
Copy link

@nada-deriv nada-deriv Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need to give the props field here since no props are being passed?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, @adrienne-deriv had informed me that we have to pass props: {} here even though we're not passing anything to the modal, if the modal has props that can be passed through, we must pass empty props here. And the error for @ts-ignore was because we didn't fix the typings for that modal prior

Screenshot 2023-09-08 at 4 46 03 PM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh.. then i think for many existing refactored cards we will have to add props field since we removed it as part of refactoring.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm could be but i think majority of the modals that have props, we do pass some props to them so it should be ok

});
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ describe('<CancelAddPaymentMethodModal />', () => {
expect(mock_on_cancel).toHaveBeenCalled();
expect(mock_modal_manager_context.hideModal).toHaveBeenCalledWith({
should_save_form_history: false,
should_restore_local_state: false,
should_hide_all_modals: true,
});
});
Expand All @@ -77,6 +78,7 @@ describe('<CancelAddPaymentMethodModal />', () => {

expect(mock_modal_manager_context.hideModal).toHaveBeenCalledWith({
should_save_form_history: false,
should_restore_local_state: false,
should_hide_all_modals: false,
});
});
Expand All @@ -87,6 +89,7 @@ describe('<CancelAddPaymentMethodModal />', () => {
userEvent.click(go_back_button);

expect(mock_modal_manager_context.hideModal).toHaveBeenCalledWith({
should_restore_local_state: true,
should_save_form_history: true,
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ const CreateAdAddPaymentMethodModal = () => {
if (selected_payment_method.length > 0 || is_form_modified) {
showModal({
key: 'CancelAddPaymentMethodModal',
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore TODO: fix typings in CancelAddPaymentMethodModal component and make them optional and remove this comment
props: {
should_hide_all_modals_on_cancel: true,
},
Expand Down