1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
4 import _ from 'lodash';
5 import { ToastrModule } from 'ngx-toastr';
6 import { of } from 'rxjs';
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';
15 describe('CreateClusterReviewComponent', () => {
16 let component: CreateClusterReviewComponent;
17 let fixture: ComponentFixture<CreateClusterReviewComponent>;
18 let cephServiceService: CephServiceService;
19 let serviceListSpy: jasmine.Spy;
22 imports: [HttpClientTestingModule, SharedModule, ToastrModule.forRoot(), CephModule, CoreModule]
26 fixture = TestBed.createComponent(CreateClusterReviewComponent);
27 component = fixture.componentInstance;
28 cephServiceService = TestBed.inject(CephServiceService);
29 serviceListSpy = spyOn(cephServiceService, 'list');
32 it('should create', () => {
33 expect(component).toBeTruthy();
36 it('should verify host metadata calculations', () => {
37 const hostnames = ['ceph.test1', 'ceph.test2'];
40 hostname: hostnames[0],
41 service_type: ['mgr', 'mon']
44 hostname: hostnames[1],
45 service_type: ['mgr', 'alertmanager']
48 serviceListSpy.and.callFake(() => of(payload));
49 fixture.detectChanges();
50 expect(serviceListSpy).toHaveBeenCalled();
52 expect(component.serviceCount).toBe(2);
53 expect(component.uniqueServices.size).toBe(2);