]>
Commit | Line | Data |
---|---|---|
a4b75251 TL |
1 | import { HttpClientTestingModule } from '@angular/common/http/testing'; |
2 | import { ComponentFixture, TestBed } from '@angular/core/testing'; | |
3 | ||
4 | import _ from 'lodash'; | |
5 | import { ToastrModule } from 'ngx-toastr'; | |
6 | import { of } from 'rxjs'; | |
7 | ||
8 | import { CephModule } from '~/app/ceph/ceph.module'; | |
9 | import { CoreModule } from '~/app/core/core.module'; | |
10 | import { CephServiceService } from '~/app/shared/api/ceph-service.service'; | |
11 | import { SharedModule } from '~/app/shared/shared.module'; | |
12 | import { configureTestBed } from '~/testing/unit-test-helper'; | |
13 | import { CreateClusterReviewComponent } from './create-cluster-review.component'; | |
14 | ||
15 | describe('CreateClusterReviewComponent', () => { | |
16 | let component: CreateClusterReviewComponent; | |
17 | let fixture: ComponentFixture<CreateClusterReviewComponent>; | |
18 | let cephServiceService: CephServiceService; | |
19 | let serviceListSpy: jasmine.Spy; | |
20 | ||
21 | configureTestBed({ | |
22 | imports: [HttpClientTestingModule, SharedModule, ToastrModule.forRoot(), CephModule, CoreModule] | |
23 | }); | |
24 | ||
25 | beforeEach(() => { | |
26 | fixture = TestBed.createComponent(CreateClusterReviewComponent); | |
27 | component = fixture.componentInstance; | |
28 | cephServiceService = TestBed.inject(CephServiceService); | |
29 | serviceListSpy = spyOn(cephServiceService, 'list'); | |
30 | }); | |
31 | ||
32 | it('should create', () => { | |
33 | expect(component).toBeTruthy(); | |
34 | }); | |
35 | ||
36 | it('should verify host metadata calculations', () => { | |
37 | const hostnames = ['ceph.test1', 'ceph.test2']; | |
38 | const payload = [ | |
39 | { | |
40 | hostname: hostnames[0], | |
41 | service_type: ['mgr', 'mon'] | |
42 | }, | |
43 | { | |
44 | hostname: hostnames[1], | |
45 | service_type: ['mgr', 'alertmanager'] | |
46 | } | |
47 | ]; | |
48 | serviceListSpy.and.callFake(() => of(payload)); | |
49 | fixture.detectChanges(); | |
50 | expect(serviceListSpy).toHaveBeenCalled(); | |
51 | ||
52 | expect(component.serviceCount).toBe(2); | |
53 | expect(component.uniqueServices.size).toBe(2); | |
54 | }); | |
55 | }); |