From 04f42f3007a5557260f7e4919286ca78b10fc8d9 Mon Sep 17 00:00:00 2001 From: Antonio Date: Thu, 12 Dec 2024 13:47:45 +0100 Subject: [PATCH] test: additional tests --- .../rewards/utils/formatter.test.ts | 90 +++++++++++++++++++ 1 file changed, 90 insertions(+) diff --git a/src/app/collective-rewards/rewards/utils/formatter.test.ts b/src/app/collective-rewards/rewards/utils/formatter.test.ts index 53acd373..daade801 100644 --- a/src/app/collective-rewards/rewards/utils/formatter.test.ts +++ b/src/app/collective-rewards/rewards/utils/formatter.test.ts @@ -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, @@ -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 }) => {