World airport dataset + distance cap on generated jobs (ISS-079, v0.44.0)
CI / build + unit + e2e (pull_request) Successful in 11m2s
CI / build + unit + e2e (pull_request) Successful in 11m2s
This commit is contained in:
+22
-13
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { parseCsv, filterEuAirports, toGeoJson, airportsHandler } from './airports';
|
||||
import { assertUniqueIcaos, filterWorldAirports, parseCsv, toGeoJson, airportsHandler } from './airports';
|
||||
|
||||
const HEADER =
|
||||
'"id","ident","type","name","latitude_deg","longitude_deg","elevation_ft","continent","iso_country","iso_region","municipality","scheduled_service","icao_code","iata_code","gps_code","local_code","home_link","wikipedia_link","keywords"';
|
||||
@@ -53,25 +53,34 @@ describe('parseCsv', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('filterEuAirports', () => {
|
||||
it('keeps EU fixed-wing airports and seaplane bases, drops the rest', () => {
|
||||
describe('filterWorldAirports (v0.44.0 — world dataset, no continent check)', () => {
|
||||
it('keeps fixed-wing airports and seaplane bases from every continent, drops the rest by type', () => {
|
||||
const rows = parseCsv(
|
||||
[
|
||||
HEADER,
|
||||
row({ ident: 'EU-SMALL', type: 'small_airport' }),
|
||||
row({ ident: 'EU-MED', type: 'medium_airport' }),
|
||||
row({ ident: 'EU-LRG', type: 'large_airport' }),
|
||||
row({ ident: 'NA-LRG', continent: 'NA', type: 'large_airport' }),
|
||||
row({ ident: 'AS-LRG', continent: 'AS', type: 'large_airport' }),
|
||||
row({ ident: 'EU-SEA', type: 'seaplane_base' }),
|
||||
row({ ident: 'EU-LEGACY', type: 'airport' }),
|
||||
row({ ident: 'EU-Helio', type: 'heliport' }),
|
||||
row({ ident: 'EU-CLOSED', type: 'closed' }),
|
||||
row({ ident: 'EU-BALLOON', type: 'balloonport' }),
|
||||
row({ ident: 'NA-SMALL', continent: 'NA' }),
|
||||
row({ ident: 'AS-LRG', continent: 'AS', type: 'large_airport' }),
|
||||
row({ ident: 'NA-Helio', continent: 'NA', type: 'heliport' }),
|
||||
row({ ident: 'AS-CLOSED', continent: 'AS', type: 'closed' }),
|
||||
].join('\n'),
|
||||
);
|
||||
const kept = filterEuAirports(rows).map((r) => r.ident);
|
||||
expect(kept.sort()).toEqual(['EU-LEGACY', 'EU-LRG', 'EU-MED', 'EU-SEA', 'EU-SMALL']);
|
||||
const kept = filterWorldAirports(rows).map((r) => r.ident);
|
||||
expect(kept.sort()).toEqual(['AS-LRG', 'EU-LEGACY', 'EU-SEA', 'EU-SMALL', 'NA-LRG']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('assertUniqueIcaos (v0.44.0 load-time guard)', () => {
|
||||
it('passes a collection with unique ICACOs and throws on the first duplicate', () => {
|
||||
const ok = toGeoJson(parseCsv([HEADER, row({ ident: 'AAAA', icao_code: 'AAAA' }), row({ ident: 'BBBB', icao_code: 'BBBB' })].join('\n')));
|
||||
expect(() => assertUniqueIcaos(ok)).not.toThrow();
|
||||
|
||||
// icao_code empty → the effective key is the ident fallback (toGeoJson), so a duplicate
|
||||
// ident must trip the guard too.
|
||||
const dup = toGeoJson(parseCsv([HEADER, row({ ident: 'CCCC', icao_code: '' }), row({ ident: 'CCCC', icao_code: '', latitude_deg: '51.0' })].join('\n')));
|
||||
expect(() => assertUniqueIcaos(dup)).toThrow(/duplicate ICAO.*CCCC/);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -102,7 +111,7 @@ describe('toGeoJson', () => {
|
||||
});
|
||||
|
||||
describe('/api/airports handler', () => {
|
||||
it('returns a valid GeoJSON FeatureCollection of EU airports', async () => {
|
||||
it('returns a valid GeoJSON FeatureCollection of world airports', async () => {
|
||||
const res = await airportsHandler();
|
||||
expect(res.status).toBe(200);
|
||||
expect(res.headers.get('content-type')).toContain('application/json');
|
||||
|
||||
Reference in New Issue
Block a user