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

describe('OnlineBoardDepartureUrlParamsResolver', () => {
    let service: OnlineBoardDepartureUrlParamsResolver;
    const parseDepartureSearchUrlParamsMock = jasmine.createSpy(
        'parseDepartureSearchUrlParams',
    );

    beforeEach(() => {
        TestBed.configureTestingModule({
            providers: [
                OnlineBoardDepartureUrlParamsResolver,
                {
                    provide: OnlineBoardUrlParserService,
                    useValue: {
                        parseDepartureSearchUrlParams:
                            parseDepartureSearchUrlParamsMock,
                    },
                },
            ],
        });

        service = TestBed.inject(OnlineBoardDepartureUrlParamsResolver);
        parseDepartureSearchUrlParamsMock.calls.reset();
    });

    it('should return online board url params with data for departure search', () => {
        const paramsMock = {
            departure: 'MOW',
            date: new Date(2022, 4, 28),
        };
        parseDepartureSearchUrlParamsMock
            .withArgs({})
            .and.returnValue(paramsMock);

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