1 import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
2 import { TestBed } from '@angular/core/testing';
4 import { configureTestBed } from '~/testing/unit-test-helper';
5 import { MgrModuleService } from './mgr-module.service';
7 describe('MgrModuleService', () => {
8 let service: MgrModuleService;
9 let httpTesting: HttpTestingController;
12 imports: [HttpClientTestingModule],
13 providers: [MgrModuleService]
17 service = TestBed.inject(MgrModuleService);
18 httpTesting = TestBed.inject(HttpTestingController);
25 it('should be created', () => {
26 expect(service).toBeTruthy();
29 it('should call list', () => {
30 service.list().subscribe();
31 const req = httpTesting.expectOne('api/mgr/module');
32 expect(req.request.method).toBe('GET');
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');
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);
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');
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');
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');