]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-trash-move-modal/rbd-trash-move-modal.component.spec.ts
import 15.2.4
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / block / rbd-trash-move-modal / rbd-trash-move-modal.component.spec.ts
index 737d6b5b66225dce64b47750e3232dc13f401eb0..f4f293dfeb2edf06ce93b33202870606d7d1bd98 100644 (file)
@@ -4,9 +4,9 @@ import { ReactiveFormsModule } from '@angular/forms';
 import { RouterTestingModule } from '@angular/router/testing';
 
 import * as moment from 'moment';
-import { ToastModule } from 'ng2-toastr';
 import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
 import { BsModalRef, BsModalService } from 'ngx-bootstrap/modal';
+import { ToastrModule } from 'ngx-toastr';
 
 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
 import { NotificationService } from '../../../shared/services/notification.service';
@@ -24,7 +24,7 @@ describe('RbdTrashMoveModalComponent', () => {
       HttpClientTestingModule,
       RouterTestingModule,
       SharedModule,
-      ToastModule.forRoot(),
+      ToastrModule.forRoot(),
       BsDatepickerModule.forRoot()
     ],
     declarations: [RbdTrashMoveModalComponent],
@@ -36,9 +36,10 @@ describe('RbdTrashMoveModalComponent', () => {
     component = fixture.componentInstance;
     httpTesting = TestBed.get(HttpTestingController);
 
-    component.metaType = 'RBD';
     component.poolName = 'foo';
     component.imageName = 'bar';
+
+    fixture.detectChanges();
   });
 
   it('should create', () => {
@@ -47,12 +48,11 @@ describe('RbdTrashMoveModalComponent', () => {
   });
 
   it('should finish running ngOnInit', () => {
-    fixture.detectChanges();
     expect(component.pattern).toEqual('foo/bar');
   });
 
   describe('should call moveImage', () => {
-    let notificationService;
+    let notificationService: NotificationService;
 
     beforeEach(() => {
       notificationService = TestBed.get(NotificationService);
@@ -67,32 +67,27 @@ describe('RbdTrashMoveModalComponent', () => {
 
     it('with normal delay', () => {
       component.moveImage();
-      const req = httpTesting.expectOne('api/block/image/foo/bar/move_trash');
+      const req = httpTesting.expectOne('api/block/image/foo%2Fbar/move_trash');
       req.flush(null);
       expect(req.request.body).toEqual({ delay: 0 });
     });
 
     it('with delay < 0', () => {
-      const oldDate = moment()
-        .subtract(24, 'hour')
-        .toDate();
+      const oldDate = moment().subtract(24, 'hour').toDate();
       component.moveForm.patchValue({ expiresAt: oldDate });
 
       component.moveImage();
-      const req = httpTesting.expectOne('api/block/image/foo/bar/move_trash');
+      const req = httpTesting.expectOne('api/block/image/foo%2Fbar/move_trash');
       req.flush(null);
       expect(req.request.body).toEqual({ delay: 0 });
     });
 
     it('with delay < 0', () => {
-      const oldDate = moment()
-        .add(24, 'hour')
-        .toISOString();
-      fixture.detectChanges();
+      const oldDate = moment().add(24, 'hour').toISOString();
       component.moveForm.patchValue({ expiresAt: oldDate });
 
       component.moveImage();
-      const req = httpTesting.expectOne('api/block/image/foo/bar/move_trash');
+      const req = httpTesting.expectOne('api/block/image/foo%2Fbar/move_trash');
       req.flush(null);
       expect(req.request.body.delay).toBeGreaterThan(86390);
     });