1 import { HttpClientTestingModule } from '@angular/common/http/testing';
2 import { ComponentFixture, TestBed } from '@angular/core/testing';
3 import { ReactiveFormsModule } from '@angular/forms';
4 import { RouterTestingModule } from '@angular/router/testing';
6 import { BsModalRef } from 'ngx-bootstrap/modal';
7 import { of } from 'rxjs';
9 import { configureTestBed, i18nProviders } from '../../../../../testing/unit-test-helper';
10 import { OsdService } from '../../../../shared/api/osd.service';
11 import { BackButtonComponent } from '../../../../shared/components/back-button/back-button.component';
12 import { ModalComponent } from '../../../../shared/components/modal/modal.component';
13 import { SubmitButtonComponent } from '../../../../shared/components/submit-button/submit-button.component';
14 import { CdFormBuilder } from '../../../../shared/forms/cd-form-builder';
15 import { OsdReweightModalComponent } from './osd-reweight-modal.component';
17 describe('OsdReweightModalComponent', () => {
18 let component: OsdReweightModalComponent;
19 let fixture: ComponentFixture<OsdReweightModalComponent>;
22 imports: [ReactiveFormsModule, HttpClientTestingModule, RouterTestingModule],
24 OsdReweightModalComponent,
26 SubmitButtonComponent,
29 providers: [OsdService, BsModalRef, CdFormBuilder, i18nProviders]
33 fixture = TestBed.createComponent(OsdReweightModalComponent);
34 component = fixture.componentInstance;
35 fixture.detectChanges();
38 it('should create', () => {
39 expect(component).toBeTruthy();
42 it('should call OsdService::reweight() on submit', () => {
44 component.reweightForm.get('weight').setValue(0.5);
46 const osdServiceSpy = spyOn(TestBed.get(OsdService), 'reweight').and.callFake(() => of(true));
49 expect(osdServiceSpy.calls.count()).toBe(1);
50 expect(osdServiceSpy.calls.first().args).toEqual([1, 0.5]);