37 lines
1.6 KiB
TypeScript
37 lines
1.6 KiB
TypeScript
|
|
import { describe, it, expect } from 'vitest';
|
||
|
|
import { MAP_CONFIG } from '@/constants';
|
||
|
|
|
||
|
|
describe('MAP_CONFIG', () => {
|
||
|
|
describe('B18 — default map center is London', () => {
|
||
|
|
it('DEFAULT_CENTER points at London, not Czech Republic', () => {
|
||
|
|
// London ≈ [-0.1276, 51.5074]. The old default ([13.38032, 49.994210])
|
||
|
|
// landed in Czech Republic which is jarring for a UK-only app.
|
||
|
|
const [lng, lat] = MAP_CONFIG.DEFAULT_CENTER;
|
||
|
|
expect(lng).toBeGreaterThan(-1);
|
||
|
|
expect(lng).toBeLessThan(1);
|
||
|
|
expect(lat).toBeGreaterThan(51);
|
||
|
|
expect(lat).toBeLessThan(52);
|
||
|
|
});
|
||
|
|
|
||
|
|
it('DEFAULT_ZOOM gives a city-level view (not continent-level)', () => {
|
||
|
|
// Anything around 10 is a city / inner-borough view in Mapbox terms.
|
||
|
|
expect(MAP_CONFIG.DEFAULT_ZOOM).toBeGreaterThanOrEqual(9);
|
||
|
|
expect(MAP_CONFIG.DEFAULT_ZOOM).toBeLessThanOrEqual(13);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
|
||
|
|
describe('B19 / B29 — Mapbox token sourced from env only', () => {
|
||
|
|
it('reads from VITE_MAPBOX_TOKEN (the test setup sets it to test-token)', () => {
|
||
|
|
// The test harness (src/__tests__/setup.ts) sets VITE_MAPBOX_TOKEN
|
||
|
|
// to "test-token". The constant module reads import.meta.env at import time.
|
||
|
|
expect(MAP_CONFIG.MAPBOX_TOKEN).toBe('test-token');
|
||
|
|
});
|
||
|
|
|
||
|
|
it('does not contain a hard-coded Mapbox public key as a fallback', () => {
|
||
|
|
// The previous code shipped a real public key (`pk.eyJ1...`). This regression
|
||
|
|
// test ensures we never leak a token into the bundle again.
|
||
|
|
expect(MAP_CONFIG.MAPBOX_TOKEN).not.toMatch(/^pk\.eyJ/);
|
||
|
|
});
|
||
|
|
});
|
||
|
|
});
|