]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/orchestrator.service.spec.ts
import 15.2.4
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / orchestrator.service.spec.ts
1 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2 import { TestBed } from '@angular/core/testing';
3
4 import { configureTestBed, i18nProviders } from '../../../testing/unit-test-helper';
5 import { OrchestratorService } from './orchestrator.service';
6
7 describe('OrchestratorService', () => {
8 let service: OrchestratorService;
9 let httpTesting: HttpTestingController;
10 const apiPath = 'api/orchestrator';
11
12 configureTestBed({
13 providers: [OrchestratorService, i18nProviders],
14 imports: [HttpClientTestingModule]
15 });
16
17 beforeEach(() => {
18 service = TestBed.get(OrchestratorService);
19 httpTesting = TestBed.get(HttpTestingController);
20 });
21
22 afterEach(() => {
23 httpTesting.verify();
24 });
25
26 it('should be created', () => {
27 expect(service).toBeTruthy();
28 });
29
30 it('should call status', () => {
31 service.status().subscribe();
32 const req = httpTesting.expectOne(`${apiPath}/status`);
33 expect(req.request.method).toBe('GET');
34 });
35
36 it('should call inventoryList', () => {
37 service.inventoryList().subscribe();
38 const req = httpTesting.expectOne(`${apiPath}/inventory`);
39 expect(req.request.method).toBe('GET');
40 });
41
42 it('should call inventoryList with a host', () => {
43 const host = 'host0';
44 service.inventoryList(host).subscribe();
45 const req = httpTesting.expectOne(`${apiPath}/inventory?hostname=${host}`);
46 expect(req.request.method).toBe('GET');
47 });
48 });