import { ReactiveFormsModule } from '@angular/forms';
import { RouterTestingModule } from '@angular/router/testing';
-import { BsModalRef } from 'ngx-bootstrap/modal';
+import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap';
import { ToastrModule } from 'ngx-toastr';
-import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
-import { NotificationService } from '../../../shared/services/notification.service';
-import { SharedModule } from '../../../shared/shared.module';
+import { NotificationService } from '~/app/shared/services/notification.service';
+import { SharedModule } from '~/app/shared/shared.module';
+import { configureTestBed } from '~/testing/unit-test-helper';
import { RbdTrashRestoreModalComponent } from './rbd-trash-restore-modal.component';
describe('RbdTrashRestoreModalComponent', () => {
SharedModule,
RouterTestingModule
],
- providers: [BsModalRef, i18nProviders]
+ providers: [NgbActiveModal]
});
beforeEach(() => {
describe('should call restore', () => {
let httpTesting: HttpTestingController;
let notificationService: NotificationService;
- let modalRef: BsModalRef;
+ let activeModal: NgbActiveModal;
let req: TestRequest;
beforeEach(() => {
- httpTesting = TestBed.get(HttpTestingController);
- notificationService = TestBed.get(NotificationService);
- modalRef = TestBed.get(BsModalRef);
+ httpTesting = TestBed.inject(HttpTestingController);
+ notificationService = TestBed.inject(NotificationService);
+ activeModal = TestBed.inject(NgbActiveModal);
component.poolName = 'foo';
component.imageName = 'bar';
component.imageId = '113cb6963793';
component.ngOnInit();
- spyOn(modalRef, 'hide').and.stub();
+ spyOn(activeModal, 'close').and.stub();
spyOn(component.restoreForm, 'setErrors').and.stub();
spyOn(notificationService, 'show').and.stub();
it('with success', () => {
req.flush(null);
expect(component.restoreForm.setErrors).toHaveBeenCalledTimes(0);
- expect(component.modalRef.hide).toHaveBeenCalledTimes(1);
+ expect(component.activeModal.close).toHaveBeenCalledTimes(1);
});
it('with failure', () => {
req.flush(null, { status: 500, statusText: 'failure' });
expect(component.restoreForm.setErrors).toHaveBeenCalledTimes(1);
- expect(component.modalRef.hide).toHaveBeenCalledTimes(0);
+ expect(component.activeModal.close).toHaveBeenCalledTimes(0);
});
});
});