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 { Permission } from '../../../shared/models/permissions';
-import { NotificationService } from '../../../shared/services/notification.service';
-import { SharedModule } from '../../../shared/shared.module';
+import { Permission } from '~/app/shared/models/permissions';
+import { NotificationService } from '~/app/shared/services/notification.service';
+import { SharedModule } from '~/app/shared/shared.module';
+import { configureTestBed } from '~/testing/unit-test-helper';
import { RbdTrashPurgeModalComponent } from './rbd-trash-purge-modal.component';
describe('RbdTrashPurgeModalComponent', () => {
RouterTestingModule
],
declarations: [RbdTrashPurgeModalComponent],
- providers: [BsModalRef, i18nProviders]
+ providers: [NgbActiveModal]
});
beforeEach(() => {
fixture = TestBed.createComponent(RbdTrashPurgeModalComponent);
- httpTesting = TestBed.get(HttpTestingController);
+ httpTesting = TestBed.inject(HttpTestingController);
component = fixture.componentInstance;
});
describe('should call purge', () => {
let notificationService: NotificationService;
- let modalRef: BsModalRef;
+ let activeModal: NgbActiveModal;
let req: TestRequest;
beforeEach(() => {
fixture.detectChanges();
- notificationService = TestBed.get(NotificationService);
- modalRef = TestBed.get(BsModalRef);
+ notificationService = TestBed.inject(NotificationService);
+ activeModal = TestBed.inject(NgbActiveModal);
component.purgeForm.patchValue({ poolName: 'foo' });
- spyOn(modalRef, 'hide').and.stub();
+ spyOn(activeModal, 'close').and.stub();
spyOn(component.purgeForm, 'setErrors').and.stub();
spyOn(notificationService, 'show').and.stub();
it('with success', () => {
req.flush(null);
expect(component.purgeForm.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.purgeForm.setErrors).toHaveBeenCalledTimes(1);
- expect(component.modalRef.hide).toHaveBeenCalledTimes(0);
+ expect(component.activeModal.close).toHaveBeenCalledTimes(0);
});
});
});