import { getBankNameFromBankAccountNumber } from './getBankNameFromBankAccountNumber';

describe('getBankNameFromBankAccountNumber', () => {
  it('returns the bank name for the code in the first 3 digits (MXN)', () => {
    expect(getBankNameFromBankAccountNumber('002010077777777771', 'MXN')).toBe(
      'BANAMEX',
    );
    expect(getBankNameFromBankAccountNumber('012180012345678905', 'MXN')).toBe(
      'BBVA BANCOMER',
    );
    expect(getBankNameFromBankAccountNumber('646', 'MXN')).toBe('STP');
  });

  it('returns null when the code is not in the catalog', () => {
    expect(getBankNameFromBankAccountNumber('999000000000000000', 'MXN')).toBe(
      null,
    );
    expect(getBankNameFromBankAccountNumber('000', 'MXN')).toBe(null);
  });

  it('returns null when the first 3 characters are not digits', () => {
    expect(getBankNameFromBankAccountNumber('', 'MXN')).toBe(null);
    expect(getBankNameFromBankAccountNumber('ab2', 'MXN')).toBe(null);
    expect(getBankNameFromBankAccountNumber('00', 'MXN')).toBe(null);
  });

  it('throws for currencies other than MXN', () => {
    expect(() =>
      getBankNameFromBankAccountNumber('002010077777777771', 'USD'),
    ).toThrow('Bank Name not implemented for USD');
    expect(() =>
      getBankNameFromBankAccountNumber('002010077777777771', 'ARS'),
    ).toThrow('Bank Name not implemented for ARS');
  });
});
