]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/osd/osd-reweight-modal/osd-reweight-modal.component.spec.ts
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / osd / osd-reweight-modal / osd-reweight-modal.component.spec.ts
CommitLineData
11fdf7f2 1import { HttpClientTestingModule } from '@angular/common/http/testing';
f67539c2 2import { NO_ERRORS_SCHEMA } from '@angular/core';
11fdf7f2
TL
3import { ComponentFixture, TestBed } from '@angular/core/testing';
4import { ReactiveFormsModule } from '@angular/forms';
5import { RouterTestingModule } from '@angular/router/testing';
6
f67539c2 7import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
11fdf7f2
TL
8import { of } from 'rxjs';
9
f67539c2
TL
10import { OsdService } from '~/app/shared/api/osd.service';
11import { BackButtonComponent } from '~/app/shared/components/back-button/back-button.component';
12import { ModalComponent } from '~/app/shared/components/modal/modal.component';
13import { SubmitButtonComponent } from '~/app/shared/components/submit-button/submit-button.component';
14import { CdFormBuilder } from '~/app/shared/forms/cd-form-builder';
15import { configureTestBed } from '~/testing/unit-test-helper';
11fdf7f2
TL
16import { OsdReweightModalComponent } from './osd-reweight-modal.component';
17
18describe('OsdReweightModalComponent', () => {
19 let component: OsdReweightModalComponent;
20 let fixture: ComponentFixture<OsdReweightModalComponent>;
21
22 configureTestBed({
23 imports: [ReactiveFormsModule, HttpClientTestingModule, RouterTestingModule],
24 declarations: [
25 OsdReweightModalComponent,
26 ModalComponent,
27 SubmitButtonComponent,
28 BackButtonComponent
29 ],
f67539c2
TL
30 schemas: [NO_ERRORS_SCHEMA],
31 providers: [OsdService, NgbActiveModal, CdFormBuilder]
11fdf7f2
TL
32 });
33
34 beforeEach(() => {
35 fixture = TestBed.createComponent(OsdReweightModalComponent);
36 component = fixture.componentInstance;
37 fixture.detectChanges();
38 });
39
40 it('should create', () => {
41 expect(component).toBeTruthy();
42 });
43
44 it('should call OsdService::reweight() on submit', () => {
45 component.osdId = 1;
46 component.reweightForm.get('weight').setValue(0.5);
47
f67539c2
TL
48 const osdServiceSpy = spyOn(TestBed.inject(OsdService), 'reweight').and.callFake(() =>
49 of(true)
50 );
11fdf7f2
TL
51 component.reweight();
52
53 expect(osdServiceSpy.calls.count()).toBe(1);
54 expect(osdServiceSpy.calls.first().args).toEqual([1, 0.5]);
55 });
56});