import { TestBed } from '@angular/core/testing';
import { ApiFormatterService } from '@shared/services/api/formatter.service';

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

    beforeEach(() => {
        TestBed.configureTestingModule({
            providers: [ApiFormatterService],
        });

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

    it('should format time', () => {
        expect(service.formatTime(undefined)).toBe(undefined);
        expect(service.formatTime('2400')).toBe('23:59:59');
        expect(service.formatTime('1200')).toBe('12:00:00');
    });

    it('should format time without seconds', () => {
        expect(service.formatTimeShort(undefined)).toBe(undefined);
        expect(service.formatTimeShort('2400')).toBe('23:59');
        expect(service.formatTimeShort('1200')).toBe('12:00');
    });

    it('should format date', () => {
        const date = new Date(2022, 4, 21);

        expect(service.formatDate(undefined)).toBe(undefined);
        expect(service.formatDate(date)).toBe('2022-05-21T00:00:00');
    });
});
