Files
TREK/client/src/utils/placeLocality.test.ts
T
Maurice 31859651d7 feat(help): rewrite the help center for v5 with a Tours section, new pictures in every language, and fix the tour planner bugs it surfaced
Every help screen checked against the v5 redesign. Tours is documented for
the first time, as a screen of its own with twelve screens under it, and
notifications get help of their own. All pictures are taken again on a
realistic demo trip, with short loops where a still cannot show the motion.
The English is plain and every language is written naturally rather than
word for word.

The switcher shows two levels at most, a screen's overview lists its
sub-screens as cards above its guides, each wiki page is linked once, and
the help sidebar is wider.

Fixes found along the way: Save to Collection keeps a tour's route, a track
dropped on the places column opens the Tours import, tour Share on desktop,
the unsaved tour draft lives on the account, a route click no longer adds
an end point, Trip places leaves the trip's tours out, Escape closes a
stage's day menu, confirms before destructive deletes, DWD warnings sharing
one id kept apart, a booking's date moves with it, and smaller fixes across
notifications, bookings, the day plan, stays, Atlas, Collections, Vacay and
the admin screens.
2026-10-22 22:29:35 +02:00

27 lines
1.7 KiB
TypeScript

// FE-UTIL-LOCALITY-001 to FE-UTIL-LOCALITY-003
import { describe, it, expect } from 'vitest'
import { placeLocality } from './placeLocality'
describe('placeLocality', () => {
it('FE-UTIL-LOCALITY-001: a resolved place is named in the reader language with its region', () => {
expect(placeLocality({ country_code: 'DE', region_name: 'Brandenburg' }, 'de')).toEqual({ country: 'Deutschland', region: 'Brandenburg' })
expect(placeLocality({ country_code: 'fr', region_name: 'Île-de-France' }, 'en')).toEqual({ country: 'France', region: 'Île-de-France' })
})
it('FE-UTIL-LOCALITY-002a: a last address part that is not a country name is not taken for one', () => {
expect(placeLocality({ address: 'Shibuya City, Tokyo' }, 'en')).toEqual({ country: null, region: null })
expect(placeLocality({ address: 'Kyoto Station, Kyoto' }, 'en')).toEqual({ country: null, region: null })
expect(placeLocality({ address: '1 Main St, Springfield, USA' }, 'en')).toEqual({ country: 'United States', region: null })
expect(placeLocality({ address: 'Pariser Platz, Berlin, Germany' }, 'de')).toEqual({ country: 'Deutschland', region: null })
})
it('FE-UTIL-LOCALITY-002: an unresolved place falls back to the country its address ends on', () => {
expect(placeLocality({ address: 'Pariser Platz, 10117 Berlin, Germany' }, 'en')).toEqual({ country: 'Germany', region: null })
expect(placeLocality({ address: 'Mildred-Harnack-Straße 11, 10243 Berlin' }, 'en')).toEqual({ country: null, region: null })
})
it('FE-UTIL-LOCALITY-003: nothing to go on gives nulls', () => {
expect(placeLocality({ address: null }, 'en')).toEqual({ country: null, region: null })
})
})