import { TestBed } from '@angular/core/testing';
import { OnlineBoardDetailsUrlParamsResolver } from '@online-board/resolvers/url-params/details-url-params.resolver';
import { OnlineBoardFlightNumberUrlParamsResolver } from '@online-board/resolvers/url-params/flight-number-url-params.resolver';
import { OnlineBoardUrlParserService } from '@online-board/services/url';

describe('OnlineBoardFlightNumberUrlParamsResolver', () => {
    let service: OnlineBoardFlightNumberUrlParamsResolver;
    const parseFlightIdMock = jasmine.createSpy('parseFlightId');

    beforeEach(() => {
        TestBed.configureTestingModule({
            providers: [
                OnlineBoardFlightNumberUrlParamsResolver,
                {
                    provide: OnlineBoardUrlParserService,
                    useValue: {
                        parseFlightId: parseFlightIdMock,
                    },
                },
            ],
        });

        service = TestBed.inject(OnlineBoardFlightNumberUrlParamsResolver);
        parseFlightIdMock.calls.reset();
    });

    it('should return online board url params with data for flight number search', () => {
        const paramsMock = {
            flightNumber: '0001',
            carrier: 'SU',
            date: new Date(2022, 4, 28),
        };
        parseFlightIdMock.withArgs({}).and.returnValue(paramsMock);

        expect(service.resolve({ params: { params: {} } } as any)).toEqual({
            flightNumber: paramsMock,
        });
    });
});
