Skip to content

Commit

Permalink
test: additional tests
Browse files Browse the repository at this point in the history
  • Loading branch information
antomor committed Dec 12, 2024
1 parent 059a68d commit 04f42f3
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions src/app/collective-rewards/rewards/utils/formatter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,66 @@ describe('formatter', () => {
let currency = 'USD'
let currencySymbol = '$'
test.each([
{
amount: parseEther('1000000'),
price: 10,
symbol,
currency,
expected: {
amount: `1,000,000 ${symbol}`,
fiatAmount: formatFiatAmount('10,000,000.00', currency, currencySymbol),
},
},
{
amount: parseEther('12345678901'),
price: 10,
symbol,
currency,
expected: {
amount: `12,345,678,901 ${symbol}`,
fiatAmount: formatFiatAmount('123,456,789,010.00', currency, currencySymbol),
},
},
{
amount: parseEther('12345678901'),
price: 0.1,
symbol,
currency,
expected: {
amount: `12,345,678,901 ${symbol}`,
fiatAmount: formatFiatAmount('1,234,567,890.10', currency, currencySymbol),
},
},
{
amount: parseEther('12345678901'),
price: 0.01,
symbol,
currency,
expected: {
amount: `12,345,678,901 ${symbol}`,
fiatAmount: formatFiatAmount('123,456,789.01', currency, currencySymbol),
},
},
{
amount: parseEther('12345678901'),
price: 0.49,
symbol,
currency,
expected: {
amount: `12,345,678,901 ${symbol}`,
fiatAmount: formatFiatAmount('6,049,382,661.49', currency, currencySymbol),
},
},
{
amount: parseEther('1000'),
price: 10,
symbol,
currency,
expected: {
amount: `1,000 ${symbol}`,
fiatAmount: formatFiatAmount('10,000.00', currency, currencySymbol),
},
},
{
amount: oneEther,
price: 10,
Expand Down Expand Up @@ -74,6 +134,36 @@ describe('formatter', () => {
currency,
expected: { amount: `<0.00001 ${symbol}`, fiatAmount: formatFiatAmount('<0.01', currency) },
},
{
amount: oneEther,
price: 100_000,
symbol,
currency,
expected: {
amount: `1.00000 ${symbol}`,
fiatAmount: formatFiatAmount('100,000.00', currency, currencySymbol),
},
},
{
amount: parseEther('100'),
price: 100_000,
symbol,
currency,
expected: {
amount: `100.00000 ${symbol}`,
fiatAmount: formatFiatAmount('10,000,000.00', currency, currencySymbol),
},
},
{
amount: parseEther('123456'),
price: 100_000,
symbol,
currency,
expected: {
amount: `123,456.00000 ${symbol}`,
fiatAmount: formatFiatAmount('12,345,600,000.00', currency, currencySymbol),
},
},
])(
'formatMetrics($amount, $price, $symbol, $currency) -> $expected.amount, $expected.fiatAmount',
({ amount, price, symbol, currency, expected }) => {
Expand Down

0 comments on commit 04f42f3

Please sign in to comment.