This commit is contained in:
Andras Schmelczer 2026-05-12 22:00:56 +01:00
parent 8708bf000d
commit 11711c57e6
38 changed files with 5361 additions and 265 deletions

View file

@ -8,6 +8,7 @@ import { createElectionVoteShareFilterKey } from './election-filter';
import { createEthnicityFilterKey } from './ethnicity-filter';
import {
POI_COUNT_2KM_FILTER_NAME,
TRANSPORT_DISTANCE_FILTER_NAME,
createPoiDistanceFilterKey,
createPoiFilterKey,
} from './poi-distance-filter';
@ -141,18 +142,18 @@ describe('api utilities', () => {
it('serializes amenity distance filters using their selected backend feature', () => {
const features: FeatureMeta[] = [
{ name: 'Distance to nearest park (km)', type: 'numeric', min: 0, max: 2 },
{ name: 'Distance to nearest Tesco (km)', type: 'numeric', min: 0, max: 5 },
{ name: 'Distance to nearest grocery store (km)', type: 'numeric', min: 0, max: 5 },
];
expect(
buildFilterString(
{
[createPoiDistanceFilterKey('Distance to nearest park (km)', 1)]: [0, 0.5],
[createPoiDistanceFilterKey('Distance to nearest Tesco (km)', 2)]: [0, 1],
[createPoiDistanceFilterKey('Distance to nearest grocery store (km)', 2)]: [0, 1],
},
features
)
).toBe('Distance to nearest park (km):0:0.5;;Distance to nearest Tesco (km):0:1');
).toBe('Distance to nearest park (km):0:0.5;;Distance to nearest grocery store (km):0:1');
});
it('serializes amenity count filters using their selected backend feature', () => {
@ -173,4 +174,23 @@ describe('api utilities', () => {
)
).toBe('Number of amenities (Cafe) within 2km:2:10');
});
it('serializes transport distance filters using their selected backend feature', () => {
const features: FeatureMeta[] = [
{ name: 'Distance to nearest amenity (Bus stop) (km)', type: 'numeric', min: 0, max: 2 },
];
expect(
buildFilterString(
{
[createPoiFilterKey(
TRANSPORT_DISTANCE_FILTER_NAME,
'Distance to nearest amenity (Bus stop) (km)',
1
)]: [0, 0.4],
},
features
)
).toBe('Distance to nearest amenity (Bus stop) (km):0:0.4');
});
});