import { splitAmounts } from './transaction-calculation';

describe('splitAmounts', () => {
  it('splits a total without losing remainder cents', () => {
    expect(splitAmounts(10, 3)).toEqual([3.34, 3.33, 3.33]);
  });

  it('keeps the entered amount when it is not a total', () => {
    expect(splitAmounts(10, 3, false)).toEqual([10, 10, 10]);
  });

  it('rejects an empty player selection', () => {
    expect(() => splitAmounts(10, 0)).toThrowError('Mindestens ein Mitglied auswählen.');
  });
});
