]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | import { HttpClientTestingModule, HttpTestingController } from '@angular/common/http/testing'; |
2 | import { TestBed } from '@angular/core/testing'; | |
3 | ||
f67539c2 | 4 | import { configureTestBed, RgwHelper } from '~/testing/unit-test-helper'; |
9f95a23c TL |
5 | import { RgwSiteService } from './rgw-site.service'; |
6 | ||
7 | describe('RgwSiteService', () => { | |
8 | let service: RgwSiteService; | |
9 | let httpTesting: HttpTestingController; | |
10 | ||
11 | configureTestBed({ | |
12 | providers: [RgwSiteService], | |
13 | imports: [HttpClientTestingModule] | |
14 | }); | |
15 | ||
16 | beforeEach(() => { | |
f67539c2 TL |
17 | service = TestBed.inject(RgwSiteService); |
18 | httpTesting = TestBed.inject(HttpTestingController); | |
19 | RgwHelper.selectDaemon(); | |
9f95a23c TL |
20 | }); |
21 | ||
22 | afterEach(() => { | |
23 | httpTesting.verify(); | |
24 | }); | |
25 | ||
26 | it('should be created', () => { | |
27 | expect(service).toBeTruthy(); | |
28 | }); | |
29 | ||
e306af50 TL |
30 | it('should contain site endpoint in GET request', () => { |
31 | service.get().subscribe(); | |
f67539c2 | 32 | const req = httpTesting.expectOne(`${service['url']}?${RgwHelper.DAEMON_QUERY_PARAM}`); |
9f95a23c TL |
33 | expect(req.request.method).toBe('GET'); |
34 | }); | |
e306af50 TL |
35 | |
36 | it('should add query param in GET request', () => { | |
37 | const query = 'placement-targets'; | |
38 | service.get(query).subscribe(); | |
f67539c2 TL |
39 | httpTesting.expectOne( |
40 | `${service['url']}?${RgwHelper.DAEMON_QUERY_PARAM}&query=placement-targets` | |
41 | ); | |
e306af50 | 42 | }); |
9f95a23c | 43 | }); |