import { describe, expect, it } from 'vitest' import { estimateNativeUsdValue, estimateTokenUsdValue, getNativeAssetDescriptor } from './nativeAssetPricing' describe('nativeAssetPricing', () => { it('resolves the chain 138 native asset descriptor', () => { expect(getNativeAssetDescriptor(138)).toEqual({ symbol: 'ETH', pricingAddress: '0xc02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2', }) }) it('estimates USD values from wei using the live asset price', () => { expect(estimateNativeUsdValue('970000000000000', 2490)).toBe('2.4153') expect(estimateNativeUsdValue('1000000000000000000', 2490)).toBe('2490') }) it('returns undefined when pricing inputs are unavailable', () => { expect(estimateNativeUsdValue(undefined, 2490)).toBeUndefined() expect(estimateNativeUsdValue('970000000000000', undefined)).toBeUndefined() expect(estimateNativeUsdValue('not-a-number', 2490)).toBeUndefined() }) it('estimates token USD values using token decimals', () => { expect(estimateTokenUsdValue('1000000', 6, 1)).toBe('1') expect(estimateTokenUsdValue('250000000', 8, 2)).toBe('5') }) it('preserves precision for large raw balances', () => { expect(estimateNativeUsdValue('123456789012345678901234567890', 2316.7203872128002)).toBeTruthy() }) })