]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/crush-rule.service.spec.ts
import 15.2.4
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / crush-rule.service.spec.ts
1 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2 import { TestBed } from '@angular/core/testing';
3
4 import { configureTestBed, i18nProviders } from '../../../testing/unit-test-helper';
5 import { CrushRuleService } from './crush-rule.service';
6
7 describe('CrushRuleService', () => {
8 let service: CrushRuleService;
9 let httpTesting: HttpTestingController;
10 const apiPath = 'api/crush_rule';
11
12 configureTestBed({
13 imports: [HttpClientTestingModule],
14 providers: [CrushRuleService, i18nProviders]
15 });
16
17 beforeEach(() => {
18 service = TestBed.get(CrushRuleService);
19 httpTesting = TestBed.get(HttpTestingController);
20 });
21
22 afterEach(() => {
23 httpTesting.verify();
24 });
25
26 it('should be created', () => {
27 expect(service).toBeTruthy();
28 });
29
30 it('should call create', () => {
31 service.create({ root: 'default', name: 'someRule', failure_domain: 'osd' }).subscribe();
32 const req = httpTesting.expectOne(apiPath);
33 expect(req.request.method).toBe('POST');
34 });
35
36 it('should call delete', () => {
37 service.delete('test').subscribe();
38 const req = httpTesting.expectOne(`${apiPath}/test`);
39 expect(req.request.method).toBe('DELETE');
40 });
41
42 it('should call getInfo', () => {
43 service.getInfo().subscribe();
44 const req = httpTesting.expectOne(`ui-${apiPath}/info`);
45 expect(req.request.method).toBe('GET');
46 });
47 });