import { ScheduleItemModel } from '@shared/models-legacy';
import { getFlightMock } from '@utils/test/get-flight.mock';
import { ScheduleDetailsDataSourceService } from './details-data-source.service';

export function getScheduleDetailsDataSourceMock(): ScheduleDetailsDataSourceService {
    const flights = [
        getFlightMock('GDX', 'MOW', '1'),
        getFlightMock('GDX', 'MQF', '2'),
        getFlightMock('IGT', 'MQF', '3'),
        getFlightMock('MAD', 'MIA', '4'),
        getFlightMock('MIA', 'AGP', '5'),
        getFlightMock('AGP', 'MLE', '6'),
        getFlightMock('MLE', 'MRS', '7'),
        getFlightMock('MRS', 'MCX', '8'),
        getFlightMock('MCX', 'SEZ', '9'),
        getFlightMock('SEZ', 'MOW', '10'),
        getFlightMock('MOW', 'BWI', '11'),
        getFlightMock('BWI', 'RIC', '12'),
        getFlightMock('RIC', 'AGP', '13'),
        getFlightMock('MRS', 'MLE', '14'),
        getFlightMock('MCX', 'MRS', '15'),
        getFlightMock('SEZ', 'MCX', '16'),
        getFlightMock('MIA', 'MOW', '17'),
        getFlightMock('MOW', 'MCX', '18'),
    ];

    return {
        flight: flights[0],
        flightLegacy: flights[0],
        flights: [flights[0]],
        flightsLegacy: [flights[0]],
        scheduleLegacy: [
            new ScheduleItemModel({
                flights: flights.slice(0, 3),
                date: new Date(2022, 4, 20),
            }),
            new ScheduleItemModel({
                flights: flights.slice(3, 6),
                date: new Date(2022, 4, 21),
            }),
            new ScheduleItemModel({
                flights: flights.slice(6, 9),
                date: new Date(2022, 4, 22),
            }),
        ],
        returnScheduleLegacy: [
            new ScheduleItemModel({
                flights: flights.slice(9, 12),
                date: new Date(2022, 4, 23),
            }),
            new ScheduleItemModel({
                flights: flights.slice(12, 15),
                date: new Date(2022, 4, 24),
            }),
            new ScheduleItemModel({
                flights: flights.slice(15, 18),
                date: new Date(2022, 4, 25),
            }),
        ],
        testUtils_swapFlight: function () {
            this.flight = flights[10]; // set flight to flight from return schedule
            this.flightLegacy = flights[10]; // set flight to flight from return schedule
        },
    } as any;
}
