import { ComponentFixture, TestBed } from '@angular/core/testing';
import { OnlineBoardStartPageTitleComponent } from '@online-board/pages/start/components/title/start-page-title.component';
import { OnlineBoardTitleService } from '@online-board/services/title.service';
import { getMockPipe } from '@shared/pipes/pipe.mock';

describe('OnlineBoardStartPageTitleComponent', () => {
    let fixture: ComponentFixture<OnlineBoardStartPageTitleComponent>;
    let component: OnlineBoardStartPageTitleComponent;

    const title = 'start page title';
    const getStartPageTitleMock = jasmine
        .createSpy('getStartPageTitle')
        .and.returnValue(title);

    beforeEach(async () => {
        await TestBed.configureTestingModule({
            declarations: [
                OnlineBoardStartPageTitleComponent,
                getMockPipe('translate'),
            ],
            providers: [
                {
                    provide: OnlineBoardTitleService,
                    useValue: {
                        getStartPageTitle: getStartPageTitleMock,
                    },
                },
            ],
        }).compileComponents();
    });

    beforeEach(() => {
        getStartPageTitleMock.calls.reset();

        fixture = TestBed.createComponent(OnlineBoardStartPageTitleComponent);
        component = fixture.componentInstance;
    });

    it('should set title in constructor', () => {
        expect(getStartPageTitleMock).toHaveBeenCalled();
        expect(component.title).toBe(title);
    });
});
