import { TestBed } from '@angular/core/testing';
import { DictionariesService } from '@modules/components/page-filters/services/dictionaries-service';
import { StationCodeValidationService } from '@shared/services/validators/station-code.service';

describe('StationCodeValidationService', () => {
    let service: StationCodeValidationService;
    const dictionariesService: Partial<DictionariesService> = {
        ready$: Promise.resolve(),
        getCityOrAirport(code: string) {
            const map = new Map();
            map.set('MOW', true);
            map.set('LED', true);

            return map.has(code) as any;
        },
    };
    beforeEach(() => {
        TestBed.configureTestingModule({
            providers: [
                StationCodeValidationService,
                {
                    provide: DictionariesService,
                    useValue: dictionariesService,
                },
            ],
        });

        service = TestBed.inject(StationCodeValidationService);
    });

    it('should validate city code', async () => {
        let result = await service.isStationCodeValid('ABA');
        expect(result).toBe(false);
        result = await service.isStationCodeValid('MOW');
        expect(result).toBe(true);
        result = await service.isStationCodeValid('LED');
        expect(result).toBe(true);
    });
});
