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

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

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

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

    it('should return online board url params with data for details page', () => {
        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({
            details: paramsMock,
        });
    });
});
