]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/performance-counter.service.spec.ts
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / performance-counter.service.spec.ts
CommitLineData
11fdf7f2
TL
1import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2import { TestBed } from '@angular/core/testing';
3
f67539c2 4import { configureTestBed } from '~/testing/unit-test-helper';
11fdf7f2
TL
5import { PerformanceCounterService } from './performance-counter.service';
6
7describe('PerformanceCounterService', () => {
8 let service: PerformanceCounterService;
9 let httpTesting: HttpTestingController;
10
11 configureTestBed({
12 providers: [PerformanceCounterService],
13 imports: [HttpClientTestingModule]
14 });
15
16 beforeEach(() => {
f67539c2
TL
17 service = TestBed.inject(PerformanceCounterService);
18 httpTesting = TestBed.inject(HttpTestingController);
11fdf7f2
TL
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', () => {
30 service.list().subscribe();
31 const req = httpTesting.expectOne('api/perf_counters');
32 expect(req.request.method).toBe('GET');
33 });
34
35 it('should call get', () => {
36 let result;
37 service.get('foo', '1').subscribe((resp) => {
38 result = resp;
39 });
40 const req = httpTesting.expectOne('api/perf_counters/foo/1');
41 expect(req.request.method).toBe('GET');
42 req.flush({ counters: [{ foo: 'bar' }] });
43 expect(result).toEqual([{ foo: 'bar' }]);
44 });
45});