]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; |
2 | import { TestBed } from '@angular/core/testing'; | |
3 | ||
4 | import { configureTestBed, i18nProviders } from '../../../testing/unit-test-helper'; | |
5 | import { NfsService } from './nfs.service'; | |
6 | ||
7 | describe('NfsService', () => { | |
8 | let service: NfsService; | |
9 | let httpTesting: HttpTestingController; | |
10 | ||
11 | configureTestBed({ | |
12 | providers: [NfsService, i18nProviders], | |
13 | imports: [HttpClientTestingModule] | |
14 | }); | |
15 | ||
16 | beforeEach(() => { | |
17 | service = TestBed.get(NfsService); | |
18 | httpTesting = TestBed.get(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/nfs-ganesha/export'); | |
32 | expect(req.request.method).toBe('GET'); | |
33 | }); | |
34 | ||
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'); | |
39 | }); | |
40 | ||
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'); | |
46 | }); | |
47 | ||
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'); | |
53 | }); | |
54 | ||
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'); | |
59 | }); | |
60 | ||
61 | it('should call lsDir', () => { | |
f91f0fd5 TL |
62 | service.lsDir('a', 'foo_dir').subscribe(); |
63 | const req = httpTesting.expectOne('ui-api/nfs-ganesha/lsdir/a?root_dir=foo_dir'); | |
11fdf7f2 TL |
64 | expect(req.request.method).toBe('GET'); |
65 | }); | |
66 | ||
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'); | |
71 | }); | |
72 | ||
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'); | |
77 | }); | |
78 | ||
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'); | |
83 | }); | |
84 | ||
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'); | |
89 | }); | |
90 | }); |