import { TestBed } from '@angular/core/testing';
import { UrlParserService } from '@shared/services/url/url-parser.service';

describe('UrlParserService', () => {
    let service: UrlParserService;

    beforeEach(() => {
        TestBed.configureTestingModule({
            providers: [UrlParserService],
        });

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

    it('should parse date', () => {
        const date = new Date(2022, 4, 21);

        expect(service.parseDate('20220521')).toEqual(date);
    });

    it('should parse flight id', () => {
        const urlParams = 'SU1234-20200528';
        const result = service.parseFlightId(urlParams);

        expect(result).toEqual({
            flightNumber: '1234',
            carrier: 'SU',
            date: new Date(2020, 4, 28),
        });
    });

    it('should parse time range', () => {
        expect(service.parseTimeRange('06002200')).toEqual({
            timeFrom: '0600',
            timeTo: '2200',
        });
    });
});
