From 834bd8ea69487d0e532badc2566ebb38d3ae5667 Mon Sep 17 00:00:00 2001 From: ameerul-deriv Date: Thu, 25 Apr 2024 12:06:21 +0800 Subject: [PATCH] fix: ts errors --- .../AdvertiserName/AdvertiserNameStats.tsx | 2 +- src/components/BuySellForm/BuySellForm.tsx | 4 +-- .../__tests__/BuySellFormFooter.spec.tsx | 2 +- .../__tests__/BuySellPaymentSection.spec.tsx | 2 +- src/components/Dropdown/Dropdown.tsx | 3 +- .../__tests__/FloatingRate.spec.tsx | 5 ++-- .../AdCreateEditErrorModal.tsx | 2 +- .../__tests__/AdCreateEditErrorModal.spec.tsx | 4 +-- .../__tests__/FilterModal.spec.tsx | 2 +- .../__tests__/NicknameModal.spec.tsx | 17 +++++++---- .../PaymentMethodCardHeader.tsx | 7 ++--- .../custom-hooks/useExtendedOrderDetails.ts | 8 ++--- .../screens/CreateEditAd/CreateEditAd.tsx | 29 ++++++++++++++----- .../MyAds/MyAdsTableRow/MyAdsTableRow.tsx | 7 +++-- .../__tests__/MyAdsTableRowView.spec.tsx | 4 +++ .../screens/OrderDetails/OrderDetails.tsx | 3 +- .../__tests__/OrderDetails.spec.tsx | 2 +- .../Orders/OrdersTableRow/OrdersTableRow.tsx | 7 +++-- .../__tests__/OrderTableRow.spec.tsx | 14 ++++++--- .../OrderDetailsProvider.tsx | 2 +- .../__tests__/OrderDetailsProvider.spec.tsx | 6 ++-- 21 files changed, 84 insertions(+), 48 deletions(-) diff --git a/src/components/AdvertiserName/AdvertiserNameStats.tsx b/src/components/AdvertiserName/AdvertiserNameStats.tsx index fb8813dd..6ddf06c9 100644 --- a/src/components/AdvertiserName/AdvertiserNameStats.tsx +++ b/src/components/AdvertiserName/AdvertiserNameStats.tsx @@ -4,7 +4,7 @@ import { OnlineStatusIcon, OnlineStatusLabel, StarRating } from '@/components'; import { getCurrentRoute } from '@/utils'; import { Text, useDevice } from '@deriv-com/ui'; import ThumbUpIcon from '../../public/ic-thumb-up.svg'; -import BlockedUserOutlineIcon from '../../public/ic-user-blocked-outline.svg?react'; +import BlockedUserOutlineIcon from '../../public/ic-user-blocked-outline.svg'; import './AdvertiserNameStats.scss'; /** diff --git a/src/components/BuySellForm/BuySellForm.tsx b/src/components/BuySellForm/BuySellForm.tsx index f1478011..fc32535e 100644 --- a/src/components/BuySellForm/BuySellForm.tsx +++ b/src/components/BuySellForm/BuySellForm.tsx @@ -79,14 +79,14 @@ const BuySellForm = ({ type, } = advert; - const avertiserPaymentMethodObjects = getPaymentMethodObjects(advertiserPaymentMethods); + const advertiserPaymentMethodObjects = getPaymentMethodObjects(advertiserPaymentMethods); const paymentMethodObjects = getPaymentMethodObjects(paymentMethods); const availablePaymentMethods = payment_method_names?.map(paymentMethod => { const isAvailable = advertiserPaymentMethods?.some(method => method.display_name === paymentMethod); return { - ...(isAvailable ? avertiserPaymentMethodObjects[paymentMethod] : paymentMethodObjects[paymentMethod]), + ...(isAvailable ? advertiserPaymentMethodObjects[paymentMethod] : paymentMethodObjects[paymentMethod]), isAvailable, }; }); diff --git a/src/components/BuySellForm/BuySellFormFooter/__tests__/BuySellFormFooter.spec.tsx b/src/components/BuySellForm/BuySellFormFooter/__tests__/BuySellFormFooter.spec.tsx index 1e4f594b..73b3bc54 100644 --- a/src/components/BuySellForm/BuySellFormFooter/__tests__/BuySellFormFooter.spec.tsx +++ b/src/components/BuySellForm/BuySellFormFooter/__tests__/BuySellFormFooter.spec.tsx @@ -27,7 +27,7 @@ describe('BuySellFormFooter', () => { expect(mockProps.onClickCancel).toHaveBeenCalled(); }); it('should handle onclick for confirm button', () => { - const newProps = { mockProps, onSubmit: jest.fn() }; + const newProps = { ...mockProps, onSubmit: jest.fn() }; render(); const confirmButton = screen.getByRole('button', { name: 'Confirm' }); confirmButton.click(); diff --git a/src/components/BuySellForm/BuySellPaymentSection/__tests__/BuySellPaymentSection.spec.tsx b/src/components/BuySellForm/BuySellPaymentSection/__tests__/BuySellPaymentSection.spec.tsx index c5ec20ef..98bdd778 100644 --- a/src/components/BuySellForm/BuySellPaymentSection/__tests__/BuySellPaymentSection.spec.tsx +++ b/src/components/BuySellForm/BuySellPaymentSection/__tests__/BuySellPaymentSection.spec.tsx @@ -5,7 +5,7 @@ import BuySellPaymentSection from '../BuySellPaymentSection'; const mockProps = { availablePaymentMethods: [], onSelectPaymentMethodCard: jest.fn(), - selectedPaymentMethodIds: ['123'], + selectedPaymentMethodIds: [123], }; const mockAvailablePaymentMethods = { diff --git a/src/components/Dropdown/Dropdown.tsx b/src/components/Dropdown/Dropdown.tsx index b2dc934d..42885b1b 100644 --- a/src/components/Dropdown/Dropdown.tsx +++ b/src/components/Dropdown/Dropdown.tsx @@ -1,10 +1,11 @@ import { FC, ReactNode, useCallback, useEffect, useState } from 'react'; import clsx from 'clsx'; import { useCombobox } from 'downshift'; -import { TextField, TextFieldProps } from '@/components'; +import { TextField } from '@/components'; import { reactNodeToString } from '@/utils'; import { LabelPairedChevronDownMdRegularIcon } from '@deriv/quill-icons'; import { Text } from '@deriv-com/ui'; +import { TextFieldProps } from '../TextField/TextField'; import './Dropdown.scss'; type TGenericSizes = '2xl' | '2xs' | '3xl' | '3xs' | '4xl' | '5xl' | '6xl' | 'lg' | 'md' | 'sm' | 'xl' | 'xs'; diff --git a/src/components/FloatingRate/__tests__/FloatingRate.spec.tsx b/src/components/FloatingRate/__tests__/FloatingRate.spec.tsx index e347a3bb..66b06474 100644 --- a/src/components/FloatingRate/__tests__/FloatingRate.spec.tsx +++ b/src/components/FloatingRate/__tests__/FloatingRate.spec.tsx @@ -1,3 +1,4 @@ +import { TCurrency } from 'types'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import FloatingRate from '../FloatingRate'; @@ -33,9 +34,9 @@ const mockProps = { changeHandler: jest.fn(), errorMessages: '', fiatCurrency: 'USD', - localCurrency: 'IDR', + localCurrency: 'IDR' as TCurrency, onChange: jest.fn(), - value: 1.1, + value: '1.1', }; describe('FloatingRate', () => { diff --git a/src/components/Modals/AdCreateEditErrorModal/AdCreateEditErrorModal.tsx b/src/components/Modals/AdCreateEditErrorModal/AdCreateEditErrorModal.tsx index 46cadade..0fa74ea4 100644 --- a/src/components/Modals/AdCreateEditErrorModal/AdCreateEditErrorModal.tsx +++ b/src/components/Modals/AdCreateEditErrorModal/AdCreateEditErrorModal.tsx @@ -9,7 +9,7 @@ type TAdCreateEditErrorModalProps = { onRequestClose: () => void; }; -type ErrorCodes = (typeof ERROR_CODES)[keyof typeof ERROR_CODES]; +export type ErrorCodes = (typeof ERROR_CODES)[keyof typeof ERROR_CODES]; type ErrorContent = { [key in ErrorCodes]?: { diff --git a/src/components/Modals/AdCreateEditErrorModal/__tests__/AdCreateEditErrorModal.spec.tsx b/src/components/Modals/AdCreateEditErrorModal/__tests__/AdCreateEditErrorModal.spec.tsx index a9ccb5f7..183bdf1f 100644 --- a/src/components/Modals/AdCreateEditErrorModal/__tests__/AdCreateEditErrorModal.spec.tsx +++ b/src/components/Modals/AdCreateEditErrorModal/__tests__/AdCreateEditErrorModal.spec.tsx @@ -1,9 +1,9 @@ import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; -import AdCreateEditErrorModal from '../AdCreateEditErrorModal'; +import AdCreateEditErrorModal, { ErrorCodes } from '../AdCreateEditErrorModal'; const mockProps = { - errorCode: 'AdvertSameLimits', + errorCode: 'AdvertSameLimits' as ErrorCodes, isModalOpen: true, onRequestClose: jest.fn(), }; diff --git a/src/components/Modals/FilterModal/__tests__/FilterModal.spec.tsx b/src/components/Modals/FilterModal/__tests__/FilterModal.spec.tsx index 55a299e3..ad219072 100644 --- a/src/components/Modals/FilterModal/__tests__/FilterModal.spec.tsx +++ b/src/components/Modals/FilterModal/__tests__/FilterModal.spec.tsx @@ -12,7 +12,7 @@ const mockProps = { setSelectedPaymentMethods: jest.fn(), }; -let mockData = [ +let mockData: { display_name: string; id: string }[] | undefined = [ { display_name: 'Alipay', id: 'alipay', diff --git a/src/components/Modals/NicknameModal/__tests__/NicknameModal.spec.tsx b/src/components/Modals/NicknameModal/__tests__/NicknameModal.spec.tsx index d333c0b2..deb88a39 100644 --- a/src/components/Modals/NicknameModal/__tests__/NicknameModal.spec.tsx +++ b/src/components/Modals/NicknameModal/__tests__/NicknameModal.spec.tsx @@ -50,14 +50,19 @@ jest.mock('@/providers/AdvertiserInfoStateProvider', () => ({ }), })); +const mockProps = { + isModalOpen: true, + onRequestClose: jest.fn(), +}; + describe('NicknameModal', () => { it('should render title and description correctly', () => { - render(); + render(); expect(screen.getByText('What’s your nickname?')).toBeVisible(); expect(screen.getByText('Others will see this on your profile, ads and charts.')).toBeVisible(); }); it('should allow users to type and submit nickname', async () => { - render(); + render(); const nicknameInput = screen.getByTestId('dt_nickname_modal_input'); @@ -85,7 +90,7 @@ describe('NicknameModal', () => { })); await (() => { - render(); + render(); }); expect(mockedReset).toBeCalled(); @@ -98,8 +103,8 @@ describe('NicknameModal', () => { mutate: mockedMutate, reset: mockedReset, })); - const mockIsModalOpen = jest.fn(); - render(); + + render(); const cancelBtn = screen.getByRole('button', { name: 'Cancel', @@ -107,6 +112,6 @@ describe('NicknameModal', () => { await userEvent.click(cancelBtn); expect(mockPush).toBeCalledWith('/buy-sell'); - expect(mockIsModalOpen).toBeCalledWith(false); + expect(mockProps.onRequestClose).toBeCalledWith(false); }); }); diff --git a/src/components/PaymentMethodCard/PaymentMethodCardHeader/PaymentMethodCardHeader.tsx b/src/components/PaymentMethodCard/PaymentMethodCardHeader/PaymentMethodCardHeader.tsx index 7ea65f3e..5049cc56 100644 --- a/src/components/PaymentMethodCard/PaymentMethodCardHeader/PaymentMethodCardHeader.tsx +++ b/src/components/PaymentMethodCard/PaymentMethodCardHeader/PaymentMethodCardHeader.tsx @@ -1,4 +1,3 @@ -import { ComponentType, SVGAttributes } from 'react'; import { THooks } from 'types'; import { FlyoutMenu } from '@/components'; import { LabelPairedEllipsisVerticalXlRegularIcon } from '@deriv/quill-icons'; @@ -33,7 +32,7 @@ const PaymentMethodCardHeader = ({ small = false, type, }: TPaymentMethodCardHeaderProps) => { - let Icon: ComponentType> = IcCashierOther; + let Icon = IcCashierOther; if (type === 'bank') { Icon = IcCashierBankTransfer; } else if (type === 'ewallet') { @@ -41,11 +40,11 @@ const PaymentMethodCardHeader = ({ } // TODO: Remember to translate these const flyoutMenuItems = [ - , - , ]; diff --git a/src/hooks/custom-hooks/useExtendedOrderDetails.ts b/src/hooks/custom-hooks/useExtendedOrderDetails.ts index 2de569e9..95dbcbbf 100644 --- a/src/hooks/custom-hooks/useExtendedOrderDetails.ts +++ b/src/hooks/custom-hooks/useExtendedOrderDetails.ts @@ -1,4 +1,4 @@ -import { THooks, TServerTime } from 'types'; +import { TCurrency, THooks, TServerTime } from 'types'; import { BUY_SELL, ORDERS_STATUS } from '@/constants'; // Update your import path import { convertToMillis, @@ -15,7 +15,7 @@ type TOrder = THooks.Order.Get; type TUserDetails = TOrder['advertiser_details'] | TOrder['client_details']; type TObject = Record; -interface ExtendedOrderDetails extends TOrder { +export interface ExtendedOrderDetails extends TOrder { counterpartyAdStatusString: TObject; displayPaymentAmount: string; hasReviewDetails: boolean; @@ -93,7 +93,7 @@ const useExtendedOrderDetails = ({ return removeTrailingZeros( FormatUtils.formatMoney( Number(this.amount_display) * Number(roundOffDecimal(this.rate, setDecimalPlaces(this.rate, 6))), - { currency: this.local_currency } + { currency: this.local_currency as TCurrency } ) ); }, @@ -203,7 +203,7 @@ const useExtendedOrderDetails = ({ get rateAmount() { return removeTrailingZeros( FormatUtils.formatMoney(this.rate, { - currency: this.local_currency, + currency: this.local_currency as TCurrency, decimalPlaces: setDecimalPlaces(this.rate, 6), }) ); diff --git a/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx b/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx index f9bcfbdd..3c482f5d 100644 --- a/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx +++ b/src/pages/my-ads/screens/CreateEditAd/CreateEditAd.tsx @@ -68,7 +68,7 @@ const CreateEditAd = () => { 'min-order': '', 'order-completion-time': `${orderPaymentPeriod ? (orderPaymentPeriod * 60).toString() : '3600'}`, 'payment-method': [], - 'preferred-countries': Object.keys(countryList), + 'preferred-countries': Object.keys(countryList as object), 'rate-type-string': rateType, 'rate-value': rateType === RATE_TYPE.FLOAT ? '-0.01' : '', }, @@ -82,15 +82,30 @@ const CreateEditAd = () => { setValue, } = methods; useEffect(() => { - if (Object.keys(countryList).length > 0 && getValues('preferred-countries').length === 0) { - setValue('preferred-countries', Object.keys(countryList)); + if (Object.keys(countryList as object).length > 0 && getValues('preferred-countries').length === 0) { + setValue('preferred-countries', Object.keys(countryList as object)); } }, [countryList, getValues, setValue]); const shouldNotShowArchiveMessageAgain = localStorage.getItem('should_not_show_auto_archive_message_again'); const onSubmit = () => { - const payload = { + type TPayload = { + amount?: number; + eligible_countries: string[]; + max_order_amount: number; + min_order_amount: number; + rate: number; + rate_type: string; + type?: 'buy' | 'sell'; + payment_method_names?: number[] | string[]; + contact_info?: string; + payment_method_ids?: number[] | string[]; + description?: string; + min_completion_rate?: number; + min_join_days?: number; + }; + const payload: TPayload = { amount: Number(getValues('amount')), eligible_countries: getValues('preferred-countries'), max_order_amount: Number(getValues('max-order')), @@ -159,7 +174,7 @@ const CreateEditAd = () => { setValue('min-join-days', advertInfo.min_join_days.toString()); setValue('min-order', advertInfo.min_order_amount.toString()); setValue('rate-value', setInitialAdRate() as string); - setValue('preferred-countries', advertInfo.eligible_countries ?? Object.keys(countryList)); + setValue('preferred-countries', advertInfo.eligible_countries ?? Object.keys(countryList as object)); setValue('order-completion-time', `${advertInfo.order_expiry_period}`); if (advertInfo.type === 'sell') { setValue('contact-details', advertInfo.contact_info); @@ -177,7 +192,7 @@ const CreateEditAd = () => { useEffect(() => { if (advertInfo && isEdit) { - setFormValues(advertInfo); + setFormValues(advertInfo as NonUndefinedValues); } }, [advertInfo, isEdit, setFormValues]); @@ -195,7 +210,7 @@ const CreateEditAd = () => {
& TProps; -const MyAdsTableRow = ({ currentRateType, showModal, ...rest }: TMyAdsTableProps) => { +const MyAdsTableRow = ({ currentRateType, showModal, ...rest }: NonUndefinedValues) => { const { isMobile } = useDevice(); const { subscribeRates } = useExchangeRates(); @@ -133,7 +133,8 @@ const MyAdsTableRow = ({ currentRateType, showModal, ...rest }: TMyAdsTableProps
- {`${FormatUtils.formatMoney(amountDealt, { currency: accountCurrency })}`} {accountCurrency} + {`${FormatUtils.formatMoney(amountDealt, { currency: accountCurrency as TCurrency })}`}{' '} + {accountCurrency}   {advertType === 'Buy' ? 'Bought' : 'Sold'} diff --git a/src/pages/my-ads/screens/MyAds/MyAdsTableRow/__tests__/MyAdsTableRowView.spec.tsx b/src/pages/my-ads/screens/MyAds/MyAdsTableRow/__tests__/MyAdsTableRowView.spec.tsx index 7ee97310..d271d4d8 100644 --- a/src/pages/my-ads/screens/MyAds/MyAdsTableRow/__tests__/MyAdsTableRowView.spec.tsx +++ b/src/pages/my-ads/screens/MyAds/MyAdsTableRow/__tests__/MyAdsTableRowView.spec.tsx @@ -56,6 +56,10 @@ const mockProps = { min_rating: 4, order_expiry_period: 900, payment_info: '', + is_floating: false, + balanceAvailable: 0, + dailyBuyLimit: '', + dailySellLimit: '', }; const mockHistory = { push: jest.fn(), diff --git a/src/pages/orders/screens/OrderDetails/OrderDetails.tsx b/src/pages/orders/screens/OrderDetails/OrderDetails.tsx index c3b9151c..6c6d0e1e 100644 --- a/src/pages/orders/screens/OrderDetails/OrderDetails.tsx +++ b/src/pages/orders/screens/OrderDetails/OrderDetails.tsx @@ -3,6 +3,7 @@ import { useHistory, useLocation, useParams } from 'react-router-dom'; import { FullPageMobileWrapper, PageReturn } from '@/components'; import { api } from '@/hooks'; import { useExtendedOrderDetails } from '@/hooks/custom-hooks'; +import { ExtendedOrderDetails } from '@/hooks/custom-hooks/useExtendedOrderDetails'; import { OrderDetailsProvider } from '@/providers/OrderDetailsProvider'; import { useAuthData } from '@deriv-com/api-hooks'; import { Button, InlineMessage, Loader, Text, useDevice } from '@deriv-com/ui'; @@ -25,7 +26,7 @@ const OrderDetails = () => { const { data: serverTime } = api.account.useServerTime(); const { data: orderDetails } = useExtendedOrderDetails({ loginId: activeAccount?.loginid, - orderDetails: orderInfo, + orderDetails: orderInfo as ExtendedOrderDetails, serverTime, }); const { isBuyOrderForUser, shouldShowLostFundsBanner } = orderDetails; diff --git a/src/pages/orders/screens/OrderDetails/__tests__/OrderDetails.spec.tsx b/src/pages/orders/screens/OrderDetails/__tests__/OrderDetails.spec.tsx index e67c8c22..f405998c 100644 --- a/src/pages/orders/screens/OrderDetails/__tests__/OrderDetails.spec.tsx +++ b/src/pages/orders/screens/OrderDetails/__tests__/OrderDetails.spec.tsx @@ -98,7 +98,7 @@ describe('', () => { isLoading: false, }); - render(); + render(); expect(screen.getByTestId('dt_derivs-loader')).toBeInTheDocument(); }); diff --git a/src/pages/orders/screens/Orders/OrdersTableRow/OrdersTableRow.tsx b/src/pages/orders/screens/Orders/OrdersTableRow/OrdersTableRow.tsx index d3181f4c..f0c61a5e 100644 --- a/src/pages/orders/screens/Orders/OrdersTableRow/OrdersTableRow.tsx +++ b/src/pages/orders/screens/Orders/OrdersTableRow/OrdersTableRow.tsx @@ -1,16 +1,17 @@ import clsx from 'clsx'; import { useHistory } from 'react-router-dom'; -import { THooks } from 'types'; +import { DeepPartial, THooks } from 'types'; import { ORDERS_STATUS, ORDERS_URL } from '@/constants'; import { api } from '@/hooks'; import { useExtendedOrderDetails, useQueryString } from '@/hooks/custom-hooks'; +import { ExtendedOrderDetails } from '@/hooks/custom-hooks/useExtendedOrderDetails'; import { OrderRatingButton, OrderStatusTag, OrderTimer } from '@/pages/orders/components'; import { getDistanceToServerTime } from '@/utils'; import { Button, Text, useDevice } from '@deriv-com/ui'; import ChatIcon from '../../../../../public/ic-chat.svg'; import './OrdersTableRow.scss'; -const OrdersTableRow = ({ ...props }: THooks.Order.GetList[number]) => { +const OrdersTableRow = ({ ...props }: DeepPartial) => { const { isMobile } = useDevice(); const { queryString } = useQueryString(); const history = useHistory(); @@ -19,7 +20,7 @@ const OrdersTableRow = ({ ...props }: THooks.Order.GetList[number]) => { const { data: serverTime } = api.account.useServerTime(); const { data: orderDetails } = useExtendedOrderDetails({ loginId: activeAccount?.loginid, - orderDetails: props, + orderDetails: props as ExtendedOrderDetails, serverTime, }); diff --git a/src/pages/orders/screens/Orders/OrdersTableRow/__tests__/OrderTableRow.spec.tsx b/src/pages/orders/screens/Orders/OrdersTableRow/__tests__/OrderTableRow.spec.tsx index 99a3c7b9..91714ec4 100644 --- a/src/pages/orders/screens/Orders/OrdersTableRow/__tests__/OrderTableRow.spec.tsx +++ b/src/pages/orders/screens/Orders/OrdersTableRow/__tests__/OrderTableRow.spec.tsx @@ -1,3 +1,4 @@ +import { THooks } from 'types'; import { useDevice } from '@deriv-com/ui'; import { render, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; @@ -32,16 +33,18 @@ const mockUseDevice = useDevice as jest.Mock; const mockProps = { account_currency: 'USD', advert_details: { - block_trade: 0, + is_block_trade: false, + block_trade: 0 as THooks.Order.GetList[number]['advert_details']['block_trade'], description: 'Created by script. Please call me 02203400', id: '116', payment_method: 'bank_transfer', - type: 'sell', + type: 'sell' as 'buy' | 'sell', }, advertiser_details: { first_name: 'QA script', id: '59', - is_online: 1, + is_online: true, + is_recommended: undefined, last_name: 'userPlOta', last_online_time: 1709818078, loginid: 'CR90000299', @@ -78,7 +81,10 @@ const mockProps = { rate: 13500, rate_display: '13500.00', status: 'completed', - type: 'buy', + type: 'buy' as 'buy' | 'sell', + is_seen: false, + review_details: undefined, + is_verification_pending: false, }; describe('OrdersTableRow', () => { it('should render the component', () => { diff --git a/src/providers/OrderDetailsProvider/OrderDetailsProvider.tsx b/src/providers/OrderDetailsProvider/OrderDetailsProvider.tsx index 4536b724..d5eae646 100644 --- a/src/providers/OrderDetailsProvider/OrderDetailsProvider.tsx +++ b/src/providers/OrderDetailsProvider/OrderDetailsProvider.tsx @@ -1,7 +1,7 @@ import { createContext, PropsWithChildren, useContext } from 'react'; import { useExtendedOrderDetails } from '@/hooks/custom-hooks'; -type TOrderDetails = ReturnType['data']; +export type TOrderDetails = ReturnType['data']; type TContextValue = { isErrorOrderInfo: boolean; diff --git a/src/providers/OrderDetailsProvider/__tests__/OrderDetailsProvider.spec.tsx b/src/providers/OrderDetailsProvider/__tests__/OrderDetailsProvider.spec.tsx index 6fea9d00..37008c5e 100644 --- a/src/providers/OrderDetailsProvider/__tests__/OrderDetailsProvider.spec.tsx +++ b/src/providers/OrderDetailsProvider/__tests__/OrderDetailsProvider.spec.tsx @@ -1,11 +1,13 @@ +import { ReactNode } from 'react'; +import { ExtendedOrderDetails } from '@/hooks/custom-hooks/useExtendedOrderDetails'; import { renderHook } from '@testing-library/react'; import { OrderDetailsProvider, useOrderDetails } from '../OrderDetailsProvider'; describe('useOrderDetails', () => { it('should return the orderDetails from context', () => { - const mockValues = { isErrorOrderInfo: false, orderDetails: 'mockOrderDetails' }; + const mockValues = { isErrorOrderInfo: false, orderDetails: { isActiveOrder: true } as ExtendedOrderDetails }; - const wrapper = ({ children }: { children: JSX.Element }) => ( + const wrapper = ({ children }: { children: ReactNode }) => ( {children} );