import { TestBed } from '@angular/core/testing';
import { LocalizationService } from '@shared/services';
import { EndpointService } from '@shared/services/api/endpoint.service';

describe('EndpointService', () => {
    let service: EndpointService;

    beforeEach(() => {
        TestBed.configureTestingModule({
            providers: [
                EndpointService,
                {
                    provide: LocalizationService,
                    useValue: {
                        Language: 'ru',
                    },
                },
            ],
        });

        service = TestBed.inject(EndpointService);
    });

    it('should build localized endpoint', () => {
        expect(service.buildLocalizedURL('board/details')).toBe(
            '/api/flights/v1.1/ru/board/details',
        );

        expect(service.buildLocalizedURL('board/details', 'v1.2')).toBe(
            '/api/flights/v1.2/ru/board/details',
        );
    });

    it('should build common url', () => {
        expect(service.buildCommonURL('getpopular', '1', 'Requests')).toBe(
            '/api/Requests/1/getpopular',
        );

        expect(service.buildCommonURL('getpopular', '1')).toBe(
            '/api/flights/1/getpopular',
        );

        expect(service.buildCommonURL('getpopular')).toBe(
            '/api/flights/v1.1/getpopular',
        );
    });
});
