import { roundMoneyForDisplay } from './roundMoneyForDisplay';

describe('roundMoneyForDisplay', () => {
  it('rounds to 2 fraction digits by default', () => {
    expect(roundMoneyForDisplay(1.005, 2)).toBe(1.01);
    expect(roundMoneyForDisplay(10.2, 2)).toBe(10.2);
  });

  it('returns 0 for non-finite input', () => {
    expect(roundMoneyForDisplay(Number.NaN, 2)).toBe(0);
    expect(roundMoneyForDisplay(Number.POSITIVE_INFINITY, 2)).toBe(0);
  });

  it('normalizes float noise (e.g. 0.1 + 0.2) to 2 fraction digits', () => {
    expect(roundMoneyForDisplay(0.1 + 0.2, 2)).toBe(0.3);
  });
});
