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

describe('OnlineBoardArrivalUrlParamsResolver', () => {
    let service: OnlineBoardArrivalUrlParamsResolver;
    const parseArrivalSearchUrlParamsMock = jasmine.createSpy(
        'parseArrivalSearchUrlParams',
    );

    beforeEach(() => {
        TestBed.configureTestingModule({
            providers: [
                OnlineBoardArrivalUrlParamsResolver,
                {
                    provide: OnlineBoardUrlParserService,
                    useValue: {
                        parseArrivalSearchUrlParams:
                            parseArrivalSearchUrlParamsMock,
                    },
                },
            ],
        });

        service = TestBed.inject(OnlineBoardArrivalUrlParamsResolver);
        parseArrivalSearchUrlParamsMock.calls.reset();
    });

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

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