]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/create-cluster/create-cluster-review.component.spec.ts
import ceph 16.2.7
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / create-cluster / create-cluster-review.component.spec.ts
CommitLineData
a4b75251
TL
1import { HttpClientTestingModule } from '@angular/common/http/testing';
2import { ComponentFixture, TestBed } from '@angular/core/testing';
3
4import _ from 'lodash';
5import { ToastrModule } from 'ngx-toastr';
6import { of } from 'rxjs';
7
8import { CephModule } from '~/app/ceph/ceph.module';
9import { CoreModule } from '~/app/core/core.module';
10import { CephServiceService } from '~/app/shared/api/ceph-service.service';
11import { SharedModule } from '~/app/shared/shared.module';
12import { configureTestBed } from '~/testing/unit-test-helper';
13import { CreateClusterReviewComponent } from './create-cluster-review.component';
14
15describe('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});