import { findCountryByCode } from '.';

describe('findCountryByCode', () => {
  it('should return a country with the longest matching prefix', () => {
    const testCountry = {
      iso2: 'AQ',
      iso3: 'ATA',
      name: 'Australian Antarctic Territory',
      phone: '+672',
    };
    expect(findCountryByCode('AQ')).toStrictEqual(testCountry);
    expect(findCountryByCode('aq')).toStrictEqual(testCountry);
  });

  it('should return null for invalid code', () => {
    expect(findCountryByCode('Wrong')).toBeNull();
    expect(findCountryByCode('')).toBeNull();
    expect(findCountryByCode('  ')).toBeNull();
  });
});
