import { ComponentFixture, TestBed } from '@angular/core/testing';
import { ScheduleStartTitleComponent } from '@schedule/pages/start/components/title/schedule-start-title.component';
import { ScheduleTitleService } from '@schedule/services/title.service';
import { getMockPipe } from '@shared/pipes/pipe.mock';

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

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

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

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

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

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