import { resolveBankAccountSectionState } from './bankAccountSectionState';

describe('resolveBankAccountSectionState', () => {
  it('keeps the bank name field disabled until the bank account number is valid', () => {
    expect(
      resolveBankAccountSectionState({ bankAccountNumberValid: false }),
    ).toMatchObject({ bankNameDisabled: true });
  });

  it('enables the bank name field once the bank account number is valid', () => {
    expect(
      resolveBankAccountSectionState({ bankAccountNumberValid: true }),
    ).toMatchObject({ bankNameDisabled: false });
  });

  it('keeps the bank name field disabled when the section is disabled, even with a valid number', () => {
    expect(
      resolveBankAccountSectionState({
        disabled: true,
        bankAccountNumberValid: true,
      }),
    ).toMatchObject({ bankNameDisabled: true });
  });

  it('marks success when a bank is found', () => {
    expect(
      resolveBankAccountSectionState({
        bankAccountNumberValid: true,
        bankFound: true,
      }),
    ).toMatchObject({ bankNameSuccess: true });
  });

  it('does not mark success when no bank is found', () => {
    expect(
      resolveBankAccountSectionState({ bankAccountNumberValid: true }),
    ).toMatchObject({ bankNameSuccess: false });
  });
});
