Files
TREK/client/src/components/Map/selectedPlaceTarget.test.ts
T
Maurice 362b1ee8d1 fix(map): a selected stay is flown to even when no pin stands for it
With the Unplanned filter on, a click on a stop in the day list moved the
map while a click on the stay chip did nothing: the map only went to a
selected place it showed as a pin, and the GL map also to one of the open
day's stops, which a stay is neither. Both renderers now look the target
up the same way, the pin first, then the day's stop, then the selected
place itself, so the map goes to the stay whatever filter hides its pin.
2026-09-23 22:11:51 +02:00

28 lines
1.0 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { selectedPlaceTarget } from './selectedPlaceTarget'
// FE-MAP-SELTARGET-001 to FE-MAP-SELTARGET-004
describe('selectedPlaceTarget', () => {
const pin = { id: 1, lat: 48, lng: 2 }
const stop = { id: 2, lat: 49, lng: 3 }
const stay = { id: 3, lat: 50, lng: 4 }
it('FE-MAP-SELTARGET-001: goes to the pin the map shows', () => {
expect(selectedPlaceTarget(1, [pin], [stop], stay)).toBe(pin)
})
it('FE-MAP-SELTARGET-002: goes to the open day\'s stop when a filter hides its pin', () => {
expect(selectedPlaceTarget(2, [pin], [stop], null)).toBe(stop)
})
it('FE-MAP-SELTARGET-003: goes to a stay that is neither a pin nor a stop of the day', () => {
expect(selectedPlaceTarget(3, [pin], [stop], stay)).toBe(stay)
})
it('FE-MAP-SELTARGET-004: goes nowhere without a selection, or for a place it does not know', () => {
expect(selectedPlaceTarget(null, [pin], [stop], stay)).toBeNull()
expect(selectedPlaceTarget(9, [pin], [stop], stay)).toBeNull()
})
})