1 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2 import { TestBed } from '@angular/core/testing';
4 import { configureTestBed, i18nProviders } from '../../../testing/unit-test-helper';
5 import { CrushRuleService } from './crush-rule.service';
7 describe('CrushRuleService', () => {
8 let service: CrushRuleService;
9 let httpTesting: HttpTestingController;
10 const apiPath = 'api/crush_rule';
13 imports: [HttpClientTestingModule],
14 providers: [CrushRuleService, i18nProviders]
18 service = TestBed.get(CrushRuleService);
19 httpTesting = TestBed.get(HttpTestingController);
26 it('should be created', () => {
27 expect(service).toBeTruthy();
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');
36 it('should call delete', () => {
37 service.delete('test').subscribe();
38 const req = httpTesting.expectOne(`${apiPath}/test`);
39 expect(req.request.method).toBe('DELETE');
42 it('should call getInfo', () => {
43 service.getInfo().subscribe();
44 const req = httpTesting.expectOne(`ui-${apiPath}/info`);
45 expect(req.request.method).toBe('GET');