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 { NfsService } from './nfs.service';
7 describe('NfsService', () => {
8 let service: NfsService;
9 let httpTesting: HttpTestingController;
12 providers: [NfsService, i18nProviders],
13 imports: [HttpClientTestingModule]
17 service = TestBed.get(NfsService);
18 httpTesting = TestBed.get(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/nfs-ganesha/export');
32 expect(req.request.method).toBe('GET');
35 it('should call get', () => {
36 service.get('cluster_id', 'export_id').subscribe();
37 const req = httpTesting.expectOne('api/nfs-ganesha/export/cluster_id/export_id');
38 expect(req.request.method).toBe('GET');
41 it('should call create', () => {
42 service.create('foo').subscribe();
43 const req = httpTesting.expectOne('api/nfs-ganesha/export');
44 expect(req.request.method).toBe('POST');
45 expect(req.request.body).toEqual('foo');
48 it('should call update', () => {
49 service.update('cluster_id', 'export_id', 'foo').subscribe();
50 const req = httpTesting.expectOne('api/nfs-ganesha/export/cluster_id/export_id');
51 expect(req.request.body).toEqual('foo');
52 expect(req.request.method).toBe('PUT');
55 it('should call delete', () => {
56 service.delete('hostName', 'exportId').subscribe();
57 const req = httpTesting.expectOne('api/nfs-ganesha/export/hostName/exportId');
58 expect(req.request.method).toBe('DELETE');
61 it('should call lsDir', () => {
62 service.lsDir('foo_dir').subscribe();
63 const req = httpTesting.expectOne('ui-api/nfs-ganesha/lsdir?root_dir=foo_dir');
64 expect(req.request.method).toBe('GET');
67 it('should call buckets', () => {
68 service.buckets('user_foo').subscribe();
69 const req = httpTesting.expectOne('ui-api/nfs-ganesha/rgw/buckets?user_id=user_foo');
70 expect(req.request.method).toBe('GET');
73 it('should call daemon', () => {
74 service.daemon().subscribe();
75 const req = httpTesting.expectOne('api/nfs-ganesha/daemon');
76 expect(req.request.method).toBe('GET');
79 it('should call start', () => {
80 service.start('host_name').subscribe();
81 const req = httpTesting.expectOne('api/nfs-ganesha/service/host_name/start');
82 expect(req.request.method).toBe('PUT');
85 it('should call stop', () => {
86 service.stop('host_name').subscribe();
87 const req = httpTesting.expectOne('api/nfs-ganesha/service/host_name/stop');
88 expect(req.request.method).toBe('PUT');