more robust normalization

This commit is contained in:
simon lehericey 2024-04-10 10:47:21 +02:00
parent 758673a355
commit 5567570d74
No known key found for this signature in database
GPG key ID: CDE670D827C7B3C5
2 changed files with 40 additions and 1 deletions

View file

@ -107,4 +107,34 @@ describe APIGeoService do
it { expect(subject[:city_name]).to eq('Paris') }
end
end
describe 'safely_normalize_city_name' do
let(:department_code) { '75' }
let(:city_code) { '75056' }
let(:fallback) { 'Paris' }
subject { APIGeoService.safely_normalize_city_name(department_code, city_code, fallback) }
context 'nominal' do
it { is_expected.to eq('Paris') }
end
context 'without department' do
let(:department_code) { nil }
it { is_expected.to eq('Paris') }
end
context 'without city_code' do
let(:city_code) { nil }
it { is_expected.to eq('Paris') }
end
context 'with a wrong department' do
let(:department_code) { 'wrong' }
it { is_expected.to eq('Paris') }
end
end
end