Affichage version

Signed-off-by: Gato <cedric@goutailler-olivier.fr>
This commit is contained in:
2026-05-31 16:06:34 +02:00
parent 9f5012e9ea
commit 11aba5dbd0
7 changed files with 288 additions and 2 deletions
@@ -0,0 +1,37 @@
import { HttpClient } from '@angular/common/http';
import { TestBed } from '@angular/core/testing';
import { of } from 'rxjs';
import { vi } from 'vitest';
import { VersionApiService } from './version-api.service';
describe('VersionApiService', () => {
let service: VersionApiService;
let httpGetMock: ReturnType<typeof vi.fn>;
beforeEach(() => {
httpGetMock = vi.fn();
TestBed.configureTestingModule({
providers: [
VersionApiService,
{ provide: HttpClient, useValue: { get: httpGetMock } },
],
});
service = TestBed.inject(VersionApiService);
});
it('should be created', () => {
expect(service).toBeTruthy();
});
it('calls GET /api/version and returns the response', () => {
httpGetMock.mockReturnValue(of({ version: '1.2.3' }));
let result: any;
service.getVersion().subscribe((r) => (result = r));
expect(httpGetMock).toHaveBeenCalledWith('/api/version');
expect(result).toEqual({ version: '1.2.3' });
});
});