import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FlightModel } from '../../../shared/models-legacy';
import { BuyTicketLogic } from '../buy-ticket-button/buy-ticket.logic';
import { FlightStatusLogic } from '../flight-status-button/flight-status.logic';
import { RegistrationLogic } from '../registration-button/registration.logic';

import { FlightActionsComponent } from './flight-actions.component';

describe('FlightActionsComponent', () => {
    let component: FlightActionsComponent;
    let fixture: ComponentFixture<FlightActionsComponent>;
    let registration: RegistrationLogic;
    let buying: BuyTicketLogic;
    let statuses: FlightStatusLogic;
    const flight: FlightModel = {} as any;

    beforeEach(async () => {
        registration = { isAnyAvailable: jasmine.createSpy().withArgs(flight).and.returnValue(Promise.resolve(true))} as any;
        buying = {available: jasmine.createSpy().withArgs(flight).and.returnValue(true) } as any;
        statuses = {available: jasmine.createSpy().withArgs(flight).and.returnValue(Promise.resolve(true)) } as any;
        await TestBed.configureTestingModule({
            declarations: [FlightActionsComponent],
            providers: [
                { provide: RegistrationLogic, useFactory: () => registration },
                { provide: BuyTicketLogic, useFactory: () => buying },
                { provide: FlightStatusLogic, useFactory: () => statuses },
            ],
        }).compileComponents();
    });

    beforeEach(() => {
        fixture = TestBed.createComponent(FlightActionsComponent);
        component = fixture.componentInstance;
        fixture.detectChanges();
    });

    it('should create', () => {
        expect(component).toBeTruthy();
    });
});
