import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing';
-import { TestBed } from '@angular/core/testing';
+import { fakeAsync, TestBed, tick } from '@angular/core/testing';
import { configureTestBed } from '~/testing/unit-test-helper';
import { NfsService } from './nfs.service';
});
it('should call update', () => {
- service.update('cluster_id', 'export_id', 'foo').subscribe();
- const req = httpTesting.expectOne('api/nfs-ganesha/export/cluster_id/export_id');
+ service.update('cluster_id', 1, 'foo').subscribe();
+ const req = httpTesting.expectOne('api/nfs-ganesha/export/cluster_id/1');
expect(req.request.body).toEqual('foo');
expect(req.request.method).toBe('PUT');
});
expect(req.request.method).toBe('GET');
});
- it('should call buckets', () => {
- service.buckets('user_foo').subscribe();
- const req = httpTesting.expectOne('ui-api/nfs-ganesha/rgw/buckets?user_id=user_foo');
- expect(req.request.method).toBe('GET');
- });
-
- it('should call daemon', () => {
- service.daemon().subscribe();
- const req = httpTesting.expectOne('api/nfs-ganesha/daemon');
- expect(req.request.method).toBe('GET');
- });
-
- it('should call start', () => {
- service.start('host_name').subscribe();
- const req = httpTesting.expectOne('api/nfs-ganesha/service/host_name/start');
- expect(req.request.method).toBe('PUT');
- });
-
- it('should call stop', () => {
- service.stop('host_name').subscribe();
- const req = httpTesting.expectOne('api/nfs-ganesha/service/host_name/stop');
- expect(req.request.method).toBe('PUT');
- });
+ it('should not call lsDir if volume is not provided', fakeAsync(() => {
+ service.lsDir('', 'foo_dir').subscribe({
+ error: (error: string) => expect(error).toEqual('Please specify a filesystem volume.')
+ });
+ tick();
+ httpTesting.expectNone('ui-api/nfs-ganesha/lsdir/?root_dir=foo_dir');
+ }));
});