]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/host.service.spec.ts
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / host.service.spec.ts
CommitLineData
11fdf7f2
TL
1import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2import { fakeAsync, TestBed, tick } from '@angular/core/testing';
3
4import { configureTestBed } from '../../../testing/unit-test-helper';
5import { HostService } from './host.service';
6
7describe('HostService', () => {
8 let service: HostService;
9 let httpTesting: HttpTestingController;
10
11 configureTestBed({
12 providers: [HostService],
13 imports: [HttpClientTestingModule]
14 });
15
16 beforeEach(() => {
17 service = TestBed.get(HostService);
18 httpTesting = TestBed.get(HttpTestingController);
19 });
20
21 afterEach(() => {
22 httpTesting.verify();
23 });
24
25 it('should be created', () => {
26 expect(service).toBeTruthy();
27 });
28
29 it('should call list', fakeAsync(() => {
30 let result;
31 service.list().then((resp) => (result = resp));
32 const req = httpTesting.expectOne('api/host');
33 expect(req.request.method).toBe('GET');
34 req.flush(['foo', 'bar']);
35 tick();
36 expect(result).toEqual(['foo', 'bar']);
37 }));
38});