import 'package:consumer_app/shared/map/map_policy.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
test('uses the product radius boundaries and 10 metre steps', () {
expect(MapPolicy.minRadiusKm, 0.01);
expect(MapPolicy.maxRadiusKm, 50);
expect(MapPolicy.radiusStepKm, 0.01);
expect(MapPolicy.radiusDivisions, 4999);
expect(MapPolicy.normalizeRadius(0.14), 0.14);
expect(MapPolicy.normalizeRadius(49.96), 49.96);
expect(MapPolicy.normalizeRadius(50), 50);
});
test('selects the configured discovery zoom bands', () {
expect(MapPolicy.zoomForRadius(0.1, fallback: 13), 16);
expect(MapPolicy.zoomForRadius(1, fallback: 13), 14);
expect(MapPolicy.zoomForRadius(10, fallback: 13), 13);
expect(MapPolicy.zoomForRadius(25, fallback: 13), 11.5);
expect(MapPolicy.zoomForRadius(50, fallback: 13), 10);
});
test('uses only centrally supplied tile templates', () {
expect(
MapPolicy.tileUrlFor(
'satellite',
'https://road.example/{z}/{x}/{y}.png',
const <String, String>{},
),
'https://road.example/{z}/{x}/{y}.png',
);
expect(
MapPolicy.tileUrlFor(
'satellite',
'https://road.example/{z}/{x}/{y}.png',
const <String, String>{
'satellite': 'https://sat.example/{z}/{x}/{y}.jpg',
},
),
'https://sat.example/{z}/{x}/{y}.jpg',
);
});
test('uses a stable screen-space cluster radius', () {
expect(MapPolicy.clusterRadiusPixels, greaterThan(0));
expect(MapPolicy.clusterRadiusPixels, lessThan(100));
});
test('includes the centrally supplied tile contact on native requests', () {
expect(
MapPolicy.tileUserAgentPackageName('https://meinweimar.de/contact'),
'de.meinweimar.consumer_app (https://meinweimar.de/contact)',
);
expect(
MapPolicy.tileUserAgentPackageName(''),
'de.meinweimar.consumer_app',
);
});
}
