import { describe, expect, it } from 'vitest'
import { formatWeiAsEth } from './format'

describe('formatWeiAsEth', () => {
  it('formats zero and whole ETH values without losing precision', () => {
    expect(formatWeiAsEth('0')).toBe('0 ETH')
    expect(formatWeiAsEth('1000000000000000000')).toBe('1 ETH')
    expect(formatWeiAsEth('123450000000000000000')).toBe('123.45 ETH')
  })

  it('truncates fractional ETH safely using bigint math', () => {
    expect(formatWeiAsEth('123456789123456789')).toBe('0.1234 ETH')
    expect(formatWeiAsEth('9007199254740993')).toBe('0.009 ETH')
  })
})
