1 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2 import { TestBed } from '@angular/core/testing';
4 import { configureTestBed } from '~/testing/unit-test-helper';
5 import { TelemetryService } from './telemetry.service';
7 describe('TelemetryService', () => {
8 let service: TelemetryService;
9 let httpTesting: HttpTestingController;
12 imports: [HttpClientTestingModule],
13 providers: [TelemetryService]
17 service = TestBed.inject(TelemetryService);
18 httpTesting = TestBed.inject(HttpTestingController);
25 it('should be created', () => {
26 expect(service).toBeTruthy();
29 it('should call getReport', () => {
30 service.getReport().subscribe();
31 const req = httpTesting.expectOne('api/telemetry/report');
32 expect(req.request.method).toBe('GET');
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');
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();
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');