Skip to content

Commit

Permalink
fix(frontend): do not format usd
Browse files Browse the repository at this point in the history
  • Loading branch information
loki344 committed Jan 29, 2025
1 parent e0dbac9 commit 7c2ddeb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
SWAP_INPUT_CURRENCY_USD_SYMBOL
} from '$lib/constants/test-ids.constants';
import type { OptionAmount } from '$lib/types/send';
import { formatUSD } from '$lib/utils/format.utils';
export let tokenAmount: OptionAmount;
export let tokenDecimals: number;
Expand All @@ -28,7 +27,7 @@
const syncDisplayValueWithTokenAmount = () => {
const newDisplayValue =
nonNullish(exchangeRate) && nonNullish(tokenAmount)
? formatUSD({ value: Number(tokenAmount) * exchangeRate, options: { symbol: false } })
? (Number(tokenAmount) * exchangeRate).toFixed(2)
: undefined;
if (Number(newDisplayValue) !== Number(displayValue)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ describe('SwapInputCurrencyUsd', () => {
expect(input).toHaveValue('');
});

it.each(['10000', '1000', '100'])('does not format usd value %s', async (value) => {
const { getByTestId } = render(SwapInputCurrencyUsd, defaultProps);
const input = getByTestId(SWAP_INPUT_CURRENCY_USD);

await fireEvent.input(input, { target: { value } });
expect(input).toHaveValue(value);
});

it('updates display value when tokenAmount changes', async () => {
const props = {
...defaultProps,
Expand Down

0 comments on commit 7c2ddeb

Please sign in to comment.