import { waitForAsync, ComponentFixture, TestBed } from '@angular/core/testing'; import { FormModalComponent } from './form.modal'; import { BsModalRef } from 'ngx-bootstrap/modal'; import { Observable } from 'rxjs'; describe('FeatureImportanceModal', () => { let component: FormModalComponent; let fixture: ComponentFixture; beforeEach(waitForAsync(() => { TestBed.configureTestingModule({ declarations: [FormModalComponent], providers: [BsModalRef], imports: [], }).compileComponents(); })); beforeEach(() => { fixture = TestBed.createComponent(FormModalComponent); component = fixture.componentInstance; component.title = 'Load Scenario'; component.cancelBtnTitle = 'Cancel'; component.submitBtnTitle = 'Load'; component.bsModalRef = new BsModalRef(); component.bsModalRef.hide = jest.fn(); component.disabledLoad$ = new Observable(); component.bsModalRef.content = { onClose: { next: jest.fn(), }, onSubmit: { next: jest.fn(), }, }; fixture.detectChanges(); }); it('should create', () => { expect(component).toBeTruthy(); }); it('should fire bsRef hide method onClose', () => { component.onClose(); expect(component.bsModalRef.hide).toHaveBeenCalled(); }); it('should call onSubmit()', () => { const event = { target: { value: '' } }; component.onSubmit(event); }); });