]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/cluster.service.spec.ts
import ceph quincy 17.2.4
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / cluster.service.spec.ts
1 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2 import { fakeAsync, TestBed } from '@angular/core/testing';
3
4 import { configureTestBed } from '~/testing/unit-test-helper';
5 import { ClusterService } from './cluster.service';
6
7 describe('ClusterService', () => {
8 let service: ClusterService;
9 let httpTesting: HttpTestingController;
10
11 configureTestBed({
12 imports: [HttpClientTestingModule],
13 providers: [ClusterService]
14 });
15
16 beforeEach(() => {
17 TestBed.configureTestingModule({});
18 service = TestBed.inject(ClusterService);
19 httpTesting = TestBed.inject(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 getStatus', () => {
31 service.getStatus().subscribe();
32 const req = httpTesting.expectOne('api/cluster');
33 expect(req.request.method).toBe('GET');
34 });
35
36 it('should update cluster status', fakeAsync(() => {
37 service.updateStatus('fakeStatus').subscribe();
38 const req = httpTesting.expectOne('api/cluster');
39 expect(req.request.method).toBe('PUT');
40 expect(req.request.body).toEqual({ status: 'fakeStatus' });
41 }));
42 });