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';
HttpClientTestingModule,
RouterTestingModule,
SharedModule,
- ToastModule.forRoot(),
+ ToastrModule.forRoot(),
BsDatepickerModule.forRoot()
],
declarations: [RbdTrashMoveModalComponent],
component = fixture.componentInstance;
httpTesting = TestBed.get(HttpTestingController);
- component.metaType = 'RBD';
component.poolName = 'foo';
component.imageName = 'bar';
+
+ fixture.detectChanges();
});
it('should create', () => {
});
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);
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);
});