vega-frontend-monorepo/apps/token/src/lib/format-number.spec.ts
m.ray 41646086e4
chore(#2179): update number formatters across frontend-monorepo (#2182)
* chore: update stagnet3 urls

* chore(#2179): remove normalized number formatter functions and update getNumberFormat

* fix(#2179): fix unit tests on all formatters

* fix(#2179): fix some cypress tests

* fix: fix  trading-accounts.cy.ts

* fix: update staking and wallet teardown tests

* chore: add e2e run-all command

* fix: wallet-eth test

* fix: fix tests in explorer and token

* fix: fix common.functions.js

* fix: fix common.functions.js in explorer

* fix(#2179): fix common.functions.js in explorer

* fix(#2179): fix common.functions.js in explorer

* fix(#2179): fix common.functions.js in explorer

Co-authored-by: Matthew Russell <mattrussell36@gmail.com>
2022-11-22 18:14:16 +00:00

17 lines
724 B
TypeScript

import { BigNumber } from './bignumber';
import { formatNumber } from './format-number';
describe('formatNumber and formatNumberPercentage', () => {
it.each([
{ v: new BigNumber(123), d: 3, o: '123.00' },
{ v: new BigNumber(123.123), d: 3, o: '123.123' },
{ v: new BigNumber(123.123), d: 6, o: '123.123' },
{ v: new BigNumber(123.123), d: 0, o: '123' },
{ v: new BigNumber(123), d: undefined, o: '123.00' }, // it default to 2 decimal places
{ v: new BigNumber(30000), d: undefined, o: '30,000.00' },
{ v: new BigNumber(3.000001), d: undefined, o: '3.000001' },
])(`formats given number with decimals correctly`, ({ v, d, o }) => {
expect(formatNumber(v, d)).toStrictEqual(o);
});
});