]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/telemetry.service.spec.ts
import 15.2.4
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / telemetry.service.spec.ts
1 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2 import { TestBed } from '@angular/core/testing';
3
4 import { configureTestBed } from '../../../testing/unit-test-helper';
5 import { TelemetryService } from './telemetry.service';
6
7 describe('TelemetryService', () => {
8 let service: TelemetryService;
9 let httpTesting: HttpTestingController;
10
11 configureTestBed({
12 imports: [HttpClientTestingModule],
13 providers: [TelemetryService]
14 });
15
16 beforeEach(() => {
17 service = TestBed.get(TelemetryService);
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 getReport', () => {
30 service.getReport().subscribe();
31 const req = httpTesting.expectOne('api/telemetry/report');
32 expect(req.request.method).toBe('GET');
33 });
34
35 it('should call enable to enable module', () => {
36 service.enable(true).subscribe();
37 const req = httpTesting.expectOne('api/telemetry');
38 expect(req.request.method).toBe('PUT');
39 expect(req.request.body.enable).toBe(true);
40 expect(req.request.body.license_name).toBe('sharing-1-0');
41 });
42
43 it('should call enable to disable module', () => {
44 service.enable(false).subscribe();
45 const req = httpTesting.expectOne('api/telemetry');
46 expect(req.request.method).toBe('PUT');
47 expect(req.request.body.enable).toBe(false);
48 expect(req.request.body.license_name).toBeUndefined();
49 });
50
51 it('should call enable to enable module by default', () => {
52 service.enable().subscribe();
53 const req = httpTesting.expectOne('api/telemetry');
54 expect(req.request.method).toBe('PUT');
55 expect(req.request.body.enable).toBe(true);
56 expect(req.request.body.license_name).toBe('sharing-1-0');
57 });
58 });