diff --git a/packages/esm-patient-orders-app/src/components/order-price-details.component.tsx b/packages/esm-patient-orders-app/src/components/order-price-details.component.tsx index 40f37dcd0..563395325 100644 --- a/packages/esm-patient-orders-app/src/components/order-price-details.component.tsx +++ b/packages/esm-patient-orders-app/src/components/order-price-details.component.tsx @@ -21,7 +21,7 @@ const OrderPriceDetailsComponent: React.FC = ({ return priceData.entry[0].resource.propertyGroup[0]?.priceComponent[0]?.amount; }, [priceData]); - const formatPrice = (amount: { value: number; currency: string }, locale = 'en'): string => { + const formatedPrice = useMemo((): string => { if (!amount) return ''; try { new Intl.NumberFormat(locale, { @@ -42,7 +42,7 @@ const OrderPriceDetailsComponent: React.FC = ({ maximumFractionDigits: 2, }).format(amount.value)} ${amount.currency}`; } - }; + }, [locale, amount]); if (isLoading) { return ; @@ -55,7 +55,7 @@ const OrderPriceDetailsComponent: React.FC = ({ return (
{t('price', 'Price')}: - {formatPrice(amount)} + {formatedPrice} ({ useOrderPrice: jest.fn(), })); -jest.mock('react-i18next', () => ({ - useTranslation: jest.fn(), -})); - -const mockUseTranslation = useTranslation as jest.Mock; describe('OrderPriceDetailsComponent', () => { const mockOrderItemUuid = 'test-uuid'; beforeEach(() => { jest.resetAllMocks(); - mockUseTranslation.mockImplementation(() => ({ - t: (key: string, fallback: string) => fallback, - i18n: { language: 'en-US' }, - })); + mockGetLocale.mockReturnValue('en-US'); }); it('renders loading skeleton when data is loading', () => { @@ -74,10 +67,7 @@ describe('OrderPriceDetailsComponent', () => { }); // Change to German locale for this test - mockUseTranslation.mockImplementation(() => ({ - t: (key: string, fallback: string) => fallback, - i18n: { language: 'de-DE' }, - })); + mockGetLocale.mockReturnValue('de-DE'); renderWithSwr();