import { RouteTypeLegacy } from '../enumerators';
import { FlightNumberPipe } from './flight-number.pipe';

describe('FlightNumberPipe', () => {
    let pipe: FlightNumberPipe;
    beforeEach(() => {
        pipe = new FlightNumberPipe();
    });

    it('should return empty for invalid inputs', () => {
        expect(pipe.transform(null)).toBe('');
        expect(pipe.transform(undefined)).toBe('');
        expect(pipe.transform({} as any)).toBe('');
        expect(pipe.transform({ routeType: RouteTypeLegacy.Direct } as any)).toBe('');
    });

    it('should return "SU 1234" for direct flight', () => {
        expect(
            pipe.transform({
                routeType: RouteTypeLegacy.Direct,
                flightId: { carrier: 'SU', flightNumber: 1234 },
            } as any),
        ).toBe('SU\u00a01234');
    });

    it('should return "SU 1234, SU 4321" for connected flight', () => {
        expect(
            pipe.transform({
                routeType: RouteTypeLegacy.Connecting,
                flights: [{ flightId: { carrier: 'SU', flightNumber: 1234 } }, { flightId: { carrier: 'SU', flightNumber: 4321 } }],
            } as any),
        ).toBe('SU\u00a01234, SU\u00a04321');
    });
});
