]>
Commit | Line | Data |
---|---|---|
f6b5b4d7 TL |
1 | import { HttpClientTestingModule } from '@angular/common/http/testing'; |
2 | import { TestBed } from '@angular/core/testing'; | |
3 | ||
4 | import { Subscriber } from 'rxjs'; | |
5 | ||
f67539c2 | 6 | import { configureTestBed } from '~/testing/unit-test-helper'; |
f6b5b4d7 TL |
7 | import { SharedModule } from '../shared.module'; |
8 | import { DocService } from './doc.service'; | |
9 | ||
10 | describe('DocService', () => { | |
11 | let service: DocService; | |
12 | ||
13 | configureTestBed({ imports: [HttpClientTestingModule, SharedModule] }); | |
14 | ||
15 | beforeEach(() => { | |
f67539c2 | 16 | service = TestBed.inject(DocService); |
f6b5b4d7 TL |
17 | }); |
18 | ||
19 | it('should be created', () => { | |
20 | expect(service).toBeTruthy(); | |
21 | }); | |
22 | ||
23 | it('should return full URL', () => { | |
f67539c2 TL |
24 | expect(service.urlGenerator('iscsi', 'foo')).toBe( |
25 | 'https://docs.ceph.com/en/foo/mgr/dashboard/#enabling-iscsi-management' | |
26 | ); | |
27 | }); | |
28 | ||
1e59de90 TL |
29 | it('should return latest version URL for main', () => { |
30 | expect(service.urlGenerator('orch', 'main')).toBe( | |
f67539c2 | 31 | 'https://docs.ceph.com/en/latest/mgr/orchestrator' |
f6b5b4d7 TL |
32 | ); |
33 | }); | |
34 | ||
35 | describe('Name of the group', () => { | |
36 | let result: string; | |
37 | let i: number; | |
38 | ||
39 | const nextSummary = (newData: any) => service['releaseDataSource'].next(newData); | |
40 | ||
41 | const callback = (response: string) => { | |
42 | i++; | |
43 | result = response; | |
44 | }; | |
45 | ||
46 | beforeEach(() => { | |
47 | i = 0; | |
48 | result = undefined; | |
49 | nextSummary(undefined); | |
50 | }); | |
51 | ||
52 | it('should call subscribeOnce without releaseName', () => { | |
53 | const subscriber = service.subscribeOnce('prometheus', callback); | |
54 | ||
55 | expect(subscriber).toEqual(jasmine.any(Subscriber)); | |
56 | expect(i).toBe(0); | |
57 | expect(result).toEqual(undefined); | |
58 | }); | |
59 | ||
60 | it('should call subscribeOnce with releaseName', () => { | |
61 | const subscriber = service.subscribeOnce('prometheus', callback); | |
62 | ||
63 | expect(subscriber).toEqual(jasmine.any(Subscriber)); | |
64 | expect(i).toBe(0); | |
65 | expect(result).toEqual(undefined); | |
66 | ||
67 | nextSummary('foo'); | |
68 | expect(result).toEqual( | |
f67539c2 | 69 | 'https://docs.ceph.com/en/foo/mgr/dashboard/#enabling-prometheus-alerting' |
f6b5b4d7 TL |
70 | ); |
71 | expect(i).toBe(1); | |
72 | expect(subscriber.closed).toBe(true); | |
73 | }); | |
74 | }); | |
75 | }); |