1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { ReactiveFormsModule } from '@angular/forms';
5 import { BsModalRef } from 'ngx-bootstrap/modal';
6 import { of } from 'rxjs';
8 import { configureTestBed } from '../../../../../testing/unit-test-helper';
9 import { OsdService } from '../../../../shared/api/osd.service';
10 import { ModalComponent } from '../../../../shared/components/modal/modal.component';
11 import { SubmitButtonComponent } from '../../../../shared/components/submit-button/submit-button.component';
12 import { CdFormBuilder } from '../../../../shared/forms/cd-form-builder';
13 import { OsdReweightModalComponent } from './osd-reweight-modal.component';
15 describe('OsdReweightModalComponent', () => {
16 let component: OsdReweightModalComponent;
17 let fixture: ComponentFixture<OsdReweightModalComponent>;
20 imports: [ReactiveFormsModule, HttpClientTestingModule],
21 declarations: [OsdReweightModalComponent, ModalComponent, SubmitButtonComponent],
22 providers: [OsdService, BsModalRef, CdFormBuilder]
26 fixture = TestBed.createComponent(OsdReweightModalComponent);
27 component = fixture.componentInstance;
28 fixture.detectChanges();
31 it('should create', () => {
32 expect(component).toBeTruthy();
35 it('should call OsdService::reweight() on submit', () => {
37 component.reweightForm.get('weight').setValue(0.5);
39 const osdServiceSpy = spyOn(TestBed.get(OsdService), 'reweight').and.callFake(() => of(true));
42 expect(osdServiceSpy.calls.count()).toBe(1);
43 expect(osdServiceSpy.calls.first().args).toEqual([1, 0.5]);