@@ -6,14 +6,15 @@ import { ComponentFixture, TestBed } from '@angular/core/testing';
66
77import { WorkspaceItemsDeletePageComponent } from './workspaceitems-delete-page.component' ;
88import { ActivatedRoute , Router } from '@angular/router' ;
9- import { NgbModal } from '@ng-bootstrap/ng-bootstrap' ;
9+ import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap' ;
1010import { TranslateModule , TranslateService } from '@ngx-translate/core' ;
1111import { NotificationsServiceStub } from '../../shared/testing/notifications-service.stub' ;
1212import { EventEmitter , NO_ERRORS_SCHEMA } from '@angular/core' ;
1313import { Location } from '@angular/common' ;
1414import { of as observableOf } from 'rxjs' ;
1515import { routeServiceStub } from '../../shared/testing/route-service.stub' ;
1616import { LocationStub } from '../../shared/testing/location.stub' ;
17+ import { By } from '@angular/platform-browser' ;
1718import { ActivatedRouteStub } from '../../shared/testing/active-router.stub' ;
1819import { createSuccessfulRemoteDataObject } from '../../shared/remote-data.utils' ;
1920import { WorkspaceItem } from '../../core/submission/models/workspaceitem.model' ;
@@ -39,13 +40,12 @@ describe('WorkspaceitemsDeletePageComponent', () => {
3940 onDefaultLangChange : new EventEmitter ( )
4041 } ;
4142
42- const modalService = {
43- open : ( ) => { /** empty */ } ,
44- } ;
45-
4643 beforeEach ( async ( ) => {
4744 await TestBed . configureTestingModule ( {
48- imports : [ TranslateModule . forRoot ( ) ] ,
45+ imports : [
46+ NgbModalModule ,
47+ TranslateModule . forRoot ( )
48+ ] ,
4949 declarations : [ WorkspaceItemsDeletePageComponent ] ,
5050 providers : [
5151 {
@@ -64,7 +64,6 @@ describe('WorkspaceitemsDeletePageComponent', () => {
6464 useValue : workspaceitemDataServiceSpy ,
6565 } ,
6666 { provide : Location , useValue : new LocationStub ( ) } ,
67- { provide : NgbModal , useValue : modalService } ,
6867 {
6968 provide : NotificationsService ,
7069 useValue : new NotificationsServiceStub ( ) ,
@@ -92,12 +91,12 @@ describe('WorkspaceitemsDeletePageComponent', () => {
9291 } ) ;
9392 } ) ;
9493
95- /* it('should delete the target workspace item', () => {
96- spyOn((component as any).modalService, 'open').and.returnValue({});
94+ it ( 'should delete the target workspace item' , ( ) => {
95+ spyOn ( ( component as any ) . modalService , 'open' ) . and . returnValue ( { result : Promise . resolve ( 'ok' ) } ) ;
9796 component . confirmDelete ( By . css ( '#delete-modal' ) ) ;
9897 fixture . detectChanges ( ) ;
9998 expect ( ( component as any ) . modalService . open ) . toHaveBeenCalled ( ) ;
100- });*/
99+ } ) ;
101100
102101 it ( 'should call workspaceItemService.delete' , ( ) => {
103102 component . sendDeleteRequest ( ) ;
0 commit comments