mirror of
https://github.com/BigBodyCobain/Shadowbroker.git
synced 2026-05-01 23:35:07 +02:00
90c2e90e2c
- Parallelized startup (60s → 15s) via ThreadPoolExecutor - Adaptive polling engine with ETag caching (no more bbox interrupts) - useCallback optimization for interpolation functions - Sliding LAYERS/INTEL edge panels replace bulky Record Panel - Modular fetcher architecture (flights, geo, infrastructure, financial, earth_observation) - Stable entity IDs for GDELT & News popups (PR #63, credit @csysp) - Admin auth (X-Admin-Key), rate limiting (slowapi), auto-updater - Docker Swarm secrets support, env_check.py validation - 85+ vitest tests, CI pipeline, geoJSON builder extraction - Server-side viewport bbox filtering reduces payloads 80%+ Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Former-commit-id: f2883150b5bc78ebc139d89cc966a76f7d7c0408
97 lines
4.1 KiB
TypeScript
97 lines
4.1 KiB
TypeScript
import { describe, it, expect } from 'vitest';
|
|
import { classifyAircraft, HELI_TYPES, TURBOPROP_TYPES, BIZJET_TYPES } from '@/utils/aircraftClassification';
|
|
|
|
describe('classifyAircraft', () => {
|
|
// ─── Helicopter classification ────────────────────────────────────────────
|
|
|
|
it('classifies known helicopter types', () => {
|
|
const heliModels = ['R22', 'R44', 'B407', 'S76', 'EC35', 'H145', 'UH60', 'AH64', 'CH47'];
|
|
for (const model of heliModels) {
|
|
expect(classifyAircraft(model)).toBe('heli');
|
|
}
|
|
});
|
|
|
|
it('classifies as heli when category hint is "heli"', () => {
|
|
expect(classifyAircraft('UNKNOWN', 'heli')).toBe('heli');
|
|
});
|
|
|
|
it('category hint "heli" overrides model-based classification', () => {
|
|
// B738 would normally be airliner, but category says heli
|
|
expect(classifyAircraft('B738', 'heli')).toBe('heli');
|
|
});
|
|
|
|
// ─── Business jet classification ──────────────────────────────────────────
|
|
|
|
it('classifies known bizjet types', () => {
|
|
const bizjetModels = ['C25A', 'C680', 'CL60', 'GLEX', 'GLF5', 'LJ45', 'FA7X'];
|
|
for (const model of bizjetModels) {
|
|
expect(classifyAircraft(model)).toBe('bizjet');
|
|
}
|
|
});
|
|
|
|
// ─── Turboprop classification ─────────────────────────────────────────────
|
|
|
|
it('classifies known turboprop types', () => {
|
|
const turbopropModels = ['AT72', 'C208', 'DHC6', 'DH8D', 'PC12', 'TBM9', 'C130'];
|
|
for (const model of turbopropModels) {
|
|
expect(classifyAircraft(model)).toBe('turboprop');
|
|
}
|
|
});
|
|
|
|
// ─── Airliner default ────────────────────────────────────────────────────
|
|
|
|
it('defaults to airliner for unknown types', () => {
|
|
expect(classifyAircraft('B738')).toBe('airliner');
|
|
expect(classifyAircraft('A320')).toBe('airliner');
|
|
expect(classifyAircraft('B77W')).toBe('airliner');
|
|
});
|
|
|
|
it('defaults to airliner for empty model string', () => {
|
|
expect(classifyAircraft('')).toBe('airliner');
|
|
});
|
|
|
|
// ─── Case insensitivity ──────────────────────────────────────────────────
|
|
|
|
it('handles lowercase model codes', () => {
|
|
expect(classifyAircraft('r22')).toBe('heli');
|
|
expect(classifyAircraft('c25a')).toBe('bizjet');
|
|
expect(classifyAircraft('at72')).toBe('turboprop');
|
|
});
|
|
|
|
it('handles mixed case model codes', () => {
|
|
expect(classifyAircraft('Dh8D')).toBe('turboprop');
|
|
expect(classifyAircraft('Glf5')).toBe('bizjet');
|
|
});
|
|
|
|
// ─── Priority order ──────────────────────────────────────────────────────
|
|
|
|
it('prioritizes heli over bizjet (if type appears in both sets)', () => {
|
|
// heli check comes first in the function
|
|
for (const model of ['B06', 'S92', 'H225']) {
|
|
expect(classifyAircraft(model)).toBe('heli');
|
|
}
|
|
});
|
|
|
|
it('prioritizes bizjet over turboprop', () => {
|
|
// PC24 appears in both BIZJET_TYPES and TURBOPROP_TYPES
|
|
// bizjet check comes before turboprop in the function
|
|
if (BIZJET_TYPES.has('PC24') && TURBOPROP_TYPES.has('PC24')) {
|
|
expect(classifyAircraft('PC24')).toBe('bizjet');
|
|
}
|
|
});
|
|
|
|
// ─── Set integrity ───────────────────────────────────────────────────────
|
|
|
|
it('HELI_TYPES set has expected minimum entries', () => {
|
|
expect(HELI_TYPES.size).toBeGreaterThan(50);
|
|
});
|
|
|
|
it('TURBOPROP_TYPES set has expected minimum entries', () => {
|
|
expect(TURBOPROP_TYPES.size).toBeGreaterThan(80);
|
|
});
|
|
|
|
it('BIZJET_TYPES set has expected minimum entries', () => {
|
|
expect(BIZJET_TYPES.size).toBeGreaterThan(50);
|
|
});
|
|
});
|