import { TestBed } from '@angular/core/testing';
import { OnlineBoardFiltersStateService } from '@shared/services/filters/online-board-filters-state.service';

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

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

        service = TestBed.inject(OnlineBoardFiltersStateService);
        service.flightNumber = '0001';
        service.flightNumberDate = new Date(2022, 4, 28);
        service.departure = 'MOW';
        service.arrival = 'KUF';
        service.timeRange = {
            timeFrom: '0000',
            timeTo: '2400',
        };
        service.routeDate = new Date(2022, 4, 28);
    });

    it('should clear flight number fields', () => {
        service.clearFlightNumber();
        expect(service.flightNumber).toBe(undefined);
        expect(service.flightNumberDate).toBe(undefined);
        expect(service.arrival).toBe('KUF');
    });

    it('should clear route fields', () => {
        service.clearRoute();
        expect(service.arrival).toBe(undefined);
        expect(service.departure).toBe(undefined);
        expect(service.timeRange).toBe(undefined);
        expect(service.routeDate).toBe(undefined);
        expect(service.flightNumber).toBe('0001');
    });

    it('should clear all fields', () => {
        service.clear();
        expect(service.selectedTab).toBe('route');
        expect(service.flightNumber).toBe(undefined);
        expect(service.flightNumberDate).toBe(undefined);
        expect(service.arrival).toBe(undefined);
        expect(service.departure).toBe(undefined);
        expect(service.timeRange).toBe(undefined);
        expect(service.routeDate).toBe(undefined);
    });

    it('should clear selected tab', () => {
        service.clearSelectedTab();
        expect(service.selectedTab).toBe(undefined);
    });
});
