/** * Test file for formatting utility functions * This file can be run with a test runner or used for manual verification */ import { formatNumber, formatSats, formatMsats, formatCurrency, formatEventPrice, formatWalletBalance } from './formatting.js' // Test data const testNumbers = [ 0, 1, 999, 1000, 1001, 9999, 10000, 10001, 99999, 100000, 100001, 999999, 1000000, 1000001, 1234567, 9999999, 10000000 ] const testSats = [ 0, 1, 999, 1000, 1001, 9999, 10000, 10001, 99999, 100000, 100001, 999999, 1000000, 1000001, 1234567, 9999999, 10000000 ] const testMsats = [ 0, 1000, 999000, 1000000, 1001000, 9999000, 10000000, 10001000, 99999000, 100000000, 100001000, 999999000, 1000000000, 1000001000, 1234567000, 9999999000, 10000000000 ] const testCurrencies = [ { amount: 0, currency: 'USD' }, { amount: 1.99, currency: 'USD' }, { amount: 999.99, currency: 'USD' }, { amount: 1000, currency: 'USD' }, { amount: 1001.50, currency: 'USD' }, { amount: 9999.99, currency: 'USD' }, { amount: 10000, currency: 'USD' }, { amount: 0, currency: 'EUR' }, { amount: 1.99, currency: 'EUR' }, { amount: 999.99, currency: 'EUR' }, { amount: 1000, currency: 'EUR' } ] const testEventPrices = [ { price: 0, currency: 'sats' }, { price: 1, currency: 'sats' }, { price: 999, currency: 'sats' }, { price: 1000, currency: 'sats' }, { price: 1001, currency: 'sats' }, { price: 9999, currency: 'sats' }, { price: 10000, currency: 'sats' }, { price: 0, currency: 'USD' }, { price: 1.99, currency: 'USD' }, { price: 999.99, currency: 'USD' }, { price: 1000, currency: 'USD' }, { price: 0, currency: 'EUR' }, { price: 1.99, currency: 'EUR' }, { price: 999.99, currency: 'EUR' }, { price: 1000, currency: 'EUR' } ] // Test functions function testFormatNumber() { console.log('Testing formatNumber function:') testNumbers.forEach(num => { const formatted = formatNumber(num) console.log(`${num} -> "${formatted}"`) }) console.log('') } function testFormatSats() { console.log('Testing formatSats function:') testSats.forEach(sats => { const formatted = formatSats(sats) console.log(`${sats} sats -> "${formatted}"`) }) console.log('') } function testFormatMsats() { console.log('Testing formatMsats function:') testMsats.forEach(msats => { const formatted = formatMsats(msats) console.log(`${msats} msats -> "${formatted}"`) }) console.log('') } function testFormatCurrency() { console.log('Testing formatCurrency function:') testCurrencies.forEach(({ amount, currency }) => { const formatted = formatCurrency(amount, currency) console.log(`${amount} ${currency} -> "${formatted}"`) }) console.log('') } function testFormatEventPrice() { console.log('Testing formatEventPrice function:') testEventPrices.forEach(({ price, currency }) => { const formatted = formatEventPrice(price, currency) console.log(`${price} ${currency} -> "${formatted}"`) }) console.log('') } function testFormatWalletBalance() { console.log('Testing formatWalletBalance function:') testMsats.forEach(msats => { const formatted = formatWalletBalance(msats) console.log(`${msats} msats -> "${formatted}"`) }) console.log('') } // Run all tests function runAllTests() { console.log('=== FORMATTING UTILITY TESTS ===\n') testFormatNumber() testFormatSats() testFormatMsats() testFormatCurrency() testFormatEventPrice() testFormatWalletBalance() console.log('=== TESTS COMPLETED ===') } // Export for manual testing export { runAllTests, testFormatNumber, testFormatSats, testFormatMsats, testFormatCurrency, testFormatEventPrice, testFormatWalletBalance } // Run tests if this file is executed directly if (typeof window !== 'undefined') { // Browser environment - add to window for console testing (window as any).formattingTests = { runAllTests, testFormatNumber, testFormatSats, testFormatMsats, testFormatCurrency, testFormatEventPrice, testFormatWalletBalance } console.log('Formatting tests available at window.formattingTests') }