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 { ErasureCodeProfile } from '../models/erasure-code-profile';
6 import { ErasureCodeProfileService } from './erasure-code-profile.service';
8 describe('ErasureCodeProfileService', () => {
9 let service: ErasureCodeProfileService;
10 let httpTesting: HttpTestingController;
11 const apiPath = 'api/erasure_code_profile';
12 const testProfile: ErasureCodeProfile = { name: 'test', plugin: 'jerasure', k: 2, m: 1 };
15 imports: [HttpClientTestingModule],
16 providers: [ErasureCodeProfileService]
20 service = TestBed.inject(ErasureCodeProfileService);
21 httpTesting = TestBed.inject(HttpTestingController);
28 it('should be created', () => {
29 expect(service).toBeTruthy();
32 it('should call list', () => {
33 service.list().subscribe();
34 const req = httpTesting.expectOne(apiPath);
35 expect(req.request.method).toBe('GET');
38 it('should call create', () => {
39 service.create(testProfile).subscribe();
40 const req = httpTesting.expectOne(apiPath);
41 expect(req.request.method).toBe('POST');
44 it('should call delete', () => {
45 service.delete('test').subscribe();
46 const req = httpTesting.expectOne(`${apiPath}/test`);
47 expect(req.request.method).toBe('DELETE');
50 it('should call getInfo', () => {
51 service.getInfo().subscribe();
52 const req = httpTesting.expectOne(`ui-${apiPath}/info`);
53 expect(req.request.method).toBe('GET');