Skip to content

Commit

Permalink
maryia/WEBREL-1322/hotfix: revert override of profit fix by old ts mi…
Browse files Browse the repository at this point in the history
…gration changes (binary-com#10317)

* revert: override of profit fix by old ts migration changes

* test: added a test case for value >= 1K
  • Loading branch information
maryia-deriv committed Sep 27, 2023
1 parent 612a122 commit 6e653fa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,16 @@ describe('AccumulatorsProfitLossText', () => {
currency: 'USD',
profit: +0.35,
};

it('should render AccumulatorsProfitLossText', () => {
render(<AccumulatorsProfitLossText {...props} />);
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(<AccumulatorsProfitLossText {...props} profit={1040} />);
const whole_number = screen.getByText(/\+1,040./i);
expect(whole_number).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>(+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<ReturnType<typeof setInterval>>();
const fading_in_timeout_id = React.useRef<ReturnType<typeof setTimeout>>();
const sliding_timeout_id = React.useRef<ReturnType<typeof setTimeout>>();
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;
Expand Down

0 comments on commit 6e653fa

Please sign in to comment.