From 6e653fabd8bf15e38abf8c0bfa76623214af4da7 Mon Sep 17 00:00:00 2001 From: Maryia <103177211+maryia-deriv@users.noreply.github.com> Date: Wed, 27 Sep 2023 08:56:21 +0300 Subject: [PATCH] maryia/WEBREL-1322/hotfix: revert override of profit fix by old ts migration changes (#10317) * revert: override of profit fix by old ts migration changes * test: added a test case for value >= 1K --- .../__tests__/accumulators-profit-loss-text.spec.tsx | 10 +++++++--- .../Markers/accumulators-profit-loss-text.tsx | 6 +++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/trader/src/Modules/SmartChart/Components/Markers/__tests__/accumulators-profit-loss-text.spec.tsx b/packages/trader/src/Modules/SmartChart/Components/Markers/__tests__/accumulators-profit-loss-text.spec.tsx index e574c88367a8..eb8505df7df9 100644 --- a/packages/trader/src/Modules/SmartChart/Components/Markers/__tests__/accumulators-profit-loss-text.spec.tsx +++ b/packages/trader/src/Modules/SmartChart/Components/Markers/__tests__/accumulators-profit-loss-text.spec.tsx @@ -13,12 +13,16 @@ describe('AccumulatorsProfitLossText', () => { currency: 'USD', profit: +0.35, }; - it('should render AccumulatorsProfitLossText', () => { render(); - const text_el = screen.getByTestId('dt_accumulator_profit_text'); - expect(text_el).toHaveClass('profit-loss-text__profit'); + const whole_number = screen.getByText(/\+0./i); + expect(whole_number).toBeInTheDocument(); expect(screen.getByText('3')).toHaveClass('profit-loss-text__sliding-tenth'); expect(screen.getByText('USD')).toHaveClass('profit-loss-text__currency'); }); + it('should render AccumulatorsProfitLossText with a value of >= 1K correctly', () => { + render(); + const whole_number = screen.getByText(/\+1,040./i); + expect(whole_number).toBeInTheDocument(); + }); }); diff --git a/packages/trader/src/Modules/SmartChart/Components/Markers/accumulators-profit-loss-text.tsx b/packages/trader/src/Modules/SmartChart/Components/Markers/accumulators-profit-loss-text.tsx index 8da3cdc21ce3..db588a2d7d40 100644 --- a/packages/trader/src/Modules/SmartChart/Components/Markers/accumulators-profit-loss-text.tsx +++ b/packages/trader/src/Modules/SmartChart/Components/Markers/accumulators-profit-loss-text.tsx @@ -29,15 +29,15 @@ const AccumulatorsProfitLossText = ({ const [is_fading_in, setIsFadingIn] = React.useState(false); const [is_sliding, setIsSliding] = React.useState(false); const formatted_profit = formatMoney(currency ?? '', profit, true, 0, 0); - const prev_profit = React.useRef(+formatted_profit); - const prev_profit_tenth = +prev_profit.current?.toFixed(2).split('.')[1][0]; + const prev_profit = React.useRef(formatted_profit); + const prev_profit_tenth = +prev_profit.current?.split('.')[1][0]; const [current_profit_tenth, setCurrentProfitTenth] = React.useState(prev_profit_tenth); const profit_tenth_ref = React.useRef(0); const interval_id_ref = React.useRef>(); const fading_in_timeout_id = React.useRef>(); const sliding_timeout_id = React.useRef>(); const profit_portions_array = formatted_profit.split('.'); - const profit_whole_number = +profit_portions_array[0]; + const profit_whole_number = profit_portions_array[0]; const profit_tenth = +profit_portions_array[1][0]; const profit_hundredths = +profit_portions_array[1].slice(1); const won = profit >= 0;