import { TestBed } from '@angular/core/testing';
import { IBreadCrumbItem } from '@components/page/breadcrumds/page-breadcrumbs.component';
import { OnlineBoardRouteSearchBreadCrumbsResolver } from '@online-board/resolvers/bread-crumbs/route-search-bread-crumbs.resolver';
import { OnlineBoardBreadCrumbService } from '@online-board/services/bread-crumb.service';

describe('OnlineBoardRouteSearchBreadCrumbsResolver', () => {
    let service: OnlineBoardRouteSearchBreadCrumbsResolver;
    const getRootBreadCrumbMock = jasmine.createSpy('getRootBreadCrumb');

    const rootBreadCrumb: IBreadCrumbItem = {
        url: 'onlineboard',
        label: 'root breadcrumb',
    };

    beforeEach(() => {
        TestBed.configureTestingModule({
            providers: [
                OnlineBoardRouteSearchBreadCrumbsResolver,
                {
                    provide: OnlineBoardBreadCrumbService,
                    useValue: {
                        getRootBreadCrumb: getRootBreadCrumbMock,
                    },
                },
            ],
        });
        service = TestBed.inject(OnlineBoardRouteSearchBreadCrumbsResolver);
        getRootBreadCrumbMock.calls.reset();
        getRootBreadCrumbMock.withArgs().and.returnValue(rootBreadCrumb);
    });

    it('should return root breadcrumb', () => {
        expect(service.resolve()).toEqual([rootBreadCrumb]);
    });
});
