45 lines
1.8 KiB
JavaScript
45 lines
1.8 KiB
JavaScript
const {
|
|
resolveDestinationLabel,
|
|
isTourismPlace,
|
|
} = require('./placesRecommendationService');
|
|
|
|
describe('resolveDestinationLabel', () => {
|
|
test('prefers administrative_area_level_1 (state) over locality', () => {
|
|
const components = [
|
|
{ long_name: 'Miramar', types: ['sublocality', 'political'] },
|
|
{ long_name: 'Panaji', types: ['locality', 'political'] },
|
|
{ long_name: 'Goa', types: ['administrative_area_level_1', 'political'] },
|
|
{ long_name: 'India', types: ['country', 'political'] },
|
|
];
|
|
expect(resolveDestinationLabel(components, 'Goa Marriott, Panaji, Goa, India')).toBe('Goa');
|
|
});
|
|
|
|
test('falls back to locality when state is missing', () => {
|
|
const components = [
|
|
{ long_name: 'Panaji', types: ['locality', 'political'] },
|
|
{ long_name: 'India', types: ['country', 'political'] },
|
|
];
|
|
expect(resolveDestinationLabel(components, 'Panaji, India')).toBe('Panaji');
|
|
});
|
|
});
|
|
|
|
describe('isTourismPlace', () => {
|
|
test('keeps beaches and tourist attractions', () => {
|
|
expect(isTourismPlace({ name: 'Calangute Beach', types: ['beach', 'natural_feature'] })).toBe(true);
|
|
expect(isTourismPlace({ name: 'Aguada Fort', types: ['tourist_attraction', 'point_of_interest'] })).toBe(true);
|
|
expect(isTourismPlace({ name: 'Reis Magos Fort', types: ['point_of_interest'], tags: ['establishment'] })).toBe(true);
|
|
});
|
|
|
|
test('drops lodging and travel agencies', () => {
|
|
expect(isTourismPlace({ name: 'Miramar Residency', types: ['lodging', 'point_of_interest'] })).toBe(false);
|
|
expect(isTourismPlace({
|
|
name: 'Make It Happen Tours',
|
|
types: ['travel_agency', 'point_of_interest'],
|
|
})).toBe(false);
|
|
});
|
|
|
|
test('drops restaurants even with point_of_interest', () => {
|
|
expect(isTourismPlace({ name: 'Cafe', types: ['restaurant', 'food', 'point_of_interest'] })).toBe(false);
|
|
});
|
|
});
|