import { TranslatePipe } from '@ngx-translate/core';
import { Transfer } from '../models-legacy';
import { StationChangePipe } from './station-change.pipe';

describe('StationChangePipe', () => {
    let translate: TranslatePipe;
    let pipe: StationChangePipe;

    beforeEach(() => {
        translate = {
            transform: jasmine
                .createSpy('transform')
                .withArgs('SHARED.AIRPORT_CHANGE')
                .and.returnValue('Смена аэропорта')
                .withArgs('SHARED.TERMINAL_CHANGE')
                .and.returnValue('Смена терминала'),
        } as any;
        pipe = new StationChangePipe(translate);
    });

    it('should return empty on empty input', () => {
        expect(pipe.transform(null)).toBe('');
        expect(pipe.transform(undefined)).toBe('');
    });

    it('should return empty on noChange transfer type', () => {
        expect(pipe.transform({ stationChange: 'noChange' } as Transfer)).toBe('');
    });

    it('should return correct value on airport transfer type', () => {
        expect(pipe.transform({ stationChange: 'airport' } as Transfer)).toBe('Смена аэропорта');
    });

    it('should return correct value on terminal transfer type', () => {
        expect(pipe.transform({ stationChange: 'terminal' } as Transfer)).toBe('Смена терминала');
    });
});
