import { ComponentFixture , TestBed , async , inject , fakeAsync , tick } from '@angular/core/testing' ; import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' ; import { Observable , of } from 'rxjs' ; import { JhiEventManager } from 'ng-jhipster' ; import { FrontendTestModule } from '../../../test.module' ; import { UserMgmtDeleteDialogComponent } from 'app/admin/user-management/user-management-delete-dialog.component' ; import { UserService } from 'app/core' ; describe ( 'Component Tests' , ( ) => { describe ( 'User Management Delete Component' , ( ) => { let comp ; let fixture ; let service ; let mockEventManager ; let mockActiveModal ; beforeEach ( async ( ( ) => { TestBed . configureTestingModule ( { imports : [ FrontendTestModule ] , declarations : [ UserMgmtDeleteDialogComponent ] } ) . overrideTemplate ( UserMgmtDeleteDialogComponent , '' ) . compileComponents ( ) ; } ) ) ; beforeEach ( ( ) => { fixture = TestBed . createComponent ( UserMgmtDeleteDialogComponent ) ; comp = fixture . componentInstance ; service = fixture . debugElement . injector . get ( UserService ) ; mockEventManager = fixture . debugElement . injector . get ( JhiEventManager ) ; mockActiveModal = fixture . debugElement . injector . get ( NgbActiveModal ) ; } ) ; describe ( 'confirmDelete' , ( ) => { it ( 'Should call delete service on confirmDelete' , inject ( [ ] , fakeAsync ( ( ) => { spyOn ( service , 'delete' ) . and . returnValue ( of ( { } ) ) ; comp . confirmDelete ( 'user' ) ; tick ( ) ; expect ( service . delete ) . toHaveBeenCalledWith ( 'user' ) ; expect ( mockActiveModal . closeSpy ) . toHaveBeenCalled ( ) ; expect ( mockEventManager . broadcastSpy ) . toHaveBeenCalled ( ) ; } ) ) ) ; } ) ; } ) ; } ) ;