Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

1.0 KB
Raw Blame
import { airportSchema, airportSearchQuerySchema } from './airport.schema';

import { describe, it, expect } from 'vitest';

describe('airportSchema', () => {
  it('accepts a full airport record', () => {
    const parsed = airportSchema.parse({
      iata: 'BER',
      icao: 'EDDB',
      name: 'Berlin Brandenburg',
      city: 'Berlin',
      country: 'DE',
      lat: 52.36,
      lng: 13.5,
      tz: 'Europe/Berlin',
    });
    expect(parsed.iata).toBe('BER');
  });

  it('allows a null icao (smaller fields can be missing one)', () => {
    expect(
      airportSchema.safeParse({
        iata: 'XXX',
        icao: null,
        name: 'Test',
        city: 'Test',
        country: 'DE',
        lat: 0,
        lng: 0,
        tz: 'UTC',
      }).success,
    ).toBe(true);
  });
});

describe('airportSearchQuerySchema', () => {
  it('treats the query as optional (the route answers [] when absent)', () => {
    expect(airportSearchQuerySchema.parse({})).toEqual({});
    expect(airportSearchQuerySchema.parse({ q: 'ber' })).toEqual({ q: 'ber' });
  });
});