]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/erasure-code-profile.service.spec.ts
import 15.2.0 Octopus source
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / erasure-code-profile.service.spec.ts
CommitLineData
11fdf7f2
TL
1import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2import { TestBed } from '@angular/core/testing';
3
4import { configureTestBed, i18nProviders } from '../../../testing/unit-test-helper';
5import { ErasureCodeProfile } from '../models/erasure-code-profile';
6import { ErasureCodeProfileService } from './erasure-code-profile.service';
7
8describe('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 };
13
14 configureTestBed({
15 imports: [HttpClientTestingModule],
16 providers: [ErasureCodeProfileService, i18nProviders]
17 });
18
19 beforeEach(() => {
20 service = TestBed.get(ErasureCodeProfileService);
21 httpTesting = TestBed.get(HttpTestingController);
22 });
23
24 afterEach(() => {
25 httpTesting.verify();
26 });
27
28 it('should be created', () => {
29 expect(service).toBeTruthy();
30 });
31
32 it('should call list', () => {
33 service.list().subscribe();
34 const req = httpTesting.expectOne(apiPath);
35 expect(req.request.method).toBe('GET');
36 });
37
38 it('should call create', () => {
39 service.create(testProfile).subscribe();
40 const req = httpTesting.expectOne(apiPath);
41 expect(req.request.method).toBe('POST');
42 });
43
11fdf7f2
TL
44 it('should call delete', () => {
45 service.delete('test').subscribe();
46 const req = httpTesting.expectOne(`${apiPath}/test`);
47 expect(req.request.method).toBe('DELETE');
48 });
49
11fdf7f2
TL
50 it('should call getInfo', () => {
51 service.getInfo().subscribe();
9f95a23c 52 const req = httpTesting.expectOne(`ui-${apiPath}/info`);
11fdf7f2
TL
53 expect(req.request.method).toBe('GET');
54 });
55});