]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/api/mgr-module.service.spec.ts
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / api / mgr-module.service.spec.ts
1 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2 import { TestBed } from '@angular/core/testing';
3
4 import { configureTestBed } from '~/testing/unit-test-helper';
5 import { MgrModuleService } from './mgr-module.service';
6
7 describe('MgrModuleService', () => {
8 let service: MgrModuleService;
9 let httpTesting: HttpTestingController;
10
11 configureTestBed({
12 imports: [HttpClientTestingModule],
13 providers: [MgrModuleService]
14 });
15
16 beforeEach(() => {
17 service = TestBed.inject(MgrModuleService);
18 httpTesting = TestBed.inject(HttpTestingController);
19 });
20
21 afterEach(() => {
22 httpTesting.verify();
23 });
24
25 it('should be created', () => {
26 expect(service).toBeTruthy();
27 });
28
29 it('should call list', () => {
30 service.list().subscribe();
31 const req = httpTesting.expectOne('api/mgr/module');
32 expect(req.request.method).toBe('GET');
33 });
34
35 it('should call getConfig', () => {
36 service.getConfig('foo').subscribe();
37 const req = httpTesting.expectOne('api/mgr/module/foo');
38 expect(req.request.method).toBe('GET');
39 });
40
41 it('should call updateConfig', () => {
42 const config = { foo: 'bar' };
43 service.updateConfig('xyz', config).subscribe();
44 const req = httpTesting.expectOne('api/mgr/module/xyz');
45 expect(req.request.method).toBe('PUT');
46 expect(req.request.body.config).toEqual(config);
47 });
48
49 it('should call enable', () => {
50 service.enable('foo').subscribe();
51 const req = httpTesting.expectOne('api/mgr/module/foo/enable');
52 expect(req.request.method).toBe('POST');
53 });
54
55 it('should call disable', () => {
56 service.disable('bar').subscribe();
57 const req = httpTesting.expectOne('api/mgr/module/bar/disable');
58 expect(req.request.method).toBe('POST');
59 });
60
61 it('should call getOptions', () => {
62 service.getOptions('foo').subscribe();
63 const req = httpTesting.expectOne('api/mgr/module/foo/options');
64 expect(req.request.method).toBe('GET');
65 });
66 });