@@ -19,11 +19,14 @@ import { of } from 'rxjs';
1919
2020import { ComColDataService } from '../../../../core/data/comcol-data.service' ;
2121import { CommunityDataService } from '../../../../core/data/community-data.service' ;
22+ import { ScriptDataService } from '../../../../core/data/processes/script-data.service' ;
2223import { Community } from '../../../../core/shared/community.model' ;
24+ import { getProcessDetailRoute } from '../../../../process-page/process-page-routing.paths' ;
2325import { NotificationsService } from '../../../notifications/notifications.service' ;
2426import {
2527 createFailedRemoteDataObject$ ,
2628 createNoContentRemoteDataObject$ ,
29+ createSuccessfulRemoteDataObject$ ,
2730} from '../../../remote-data.utils' ;
2831import { NotificationsServiceStub } from '../../../testing/notifications-service.stub' ;
2932import { DeleteComColPageComponent } from './delete-comcol-page.component' ;
@@ -41,9 +44,8 @@ describe('DeleteComColPageComponent', () => {
4144 let routeStub ;
4245 let notificationsService ;
4346 let translateServiceStub ;
44- let requestServiceStub ;
45-
4647 let scheduler ;
48+ let scriptService ;
4749
4850 const validUUID = 'valid-uuid' ;
4951 const invalidUUID = 'invalid-uuid' ;
@@ -98,11 +100,16 @@ describe('DeleteComColPageComponent', () => {
98100
99101 beforeEach ( waitForAsync ( ( ) => {
100102 initializeVars ( ) ;
103+ scriptService = jasmine . createSpyObj ( 'scriptService' , {
104+ invoke : createSuccessfulRemoteDataObject$ ( { processId : '123' } ) ,
105+ } ) ;
106+ router = jasmine . createSpyObj ( 'router' , [ 'navigateByUrl' , 'navigate' ] ) ;
101107 TestBed . configureTestingModule ( {
102108 imports : [ TranslateModule . forRoot ( ) , CommonModule , RouterTestingModule ] ,
103109 providers : [
104110 { provide : ComColDataService , useValue : dsoDataService } ,
105- { provide : Router , useValue : routerStub } ,
111+ { provide : ScriptDataService , useValue : scriptService } ,
112+ { provide : Router , useValue : router } ,
106113 { provide : ActivatedRoute , useValue : routeStub } ,
107114 { provide : NotificationsService , useValue : new NotificationsServiceStub ( ) } ,
108115 { provide : TranslateService , useValue : translateServiceStub } ,
@@ -159,8 +166,7 @@ describe('DeleteComColPageComponent', () => {
159166 } ) ;
160167
161168 it ( 'should show an error notification on failure' , ( ) => {
162- ( dsoDataService . delete as any ) . and . returnValue ( createFailedRemoteDataObject$ ( 'Error' , 500 ) ) ;
163- spyOn ( router , 'navigate' ) ;
169+ ( scriptService . invoke as any ) . and . returnValue ( createFailedRemoteDataObject$ ( 'Error' , 500 ) ) ;
164170 scheduler . schedule ( ( ) => comp . onConfirm ( data2 ) ) ;
165171 scheduler . flush ( ) ;
166172 fixture . detectChanges ( ) ;
@@ -169,18 +175,17 @@ describe('DeleteComColPageComponent', () => {
169175 } ) ;
170176
171177 it ( 'should show a success notification on success and navigate' , ( ) => {
172- spyOn ( router , 'navigate' ) ;
173178 scheduler . schedule ( ( ) => comp . onConfirm ( data1 ) ) ;
174179 scheduler . flush ( ) ;
175180 fixture . detectChanges ( ) ;
176181 expect ( notificationsService . success ) . toHaveBeenCalled ( ) ;
177- expect ( router . navigate ) . toHaveBeenCalled ( ) ;
182+ expect ( router . navigateByUrl ) . toHaveBeenCalledWith ( getProcessDetailRoute ( '123' ) ) ;
178183 } ) ;
179184
180- it ( 'should call delete on the data service' , ( ) => {
185+ it ( 'should call script service invoke ' , ( ) => {
181186 comp . onConfirm ( data1 ) ;
182187 fixture . detectChanges ( ) ;
183- expect ( dsoDataService . delete ) . toHaveBeenCalledWith ( data1 . id ) ;
188+ expect ( scriptService . invoke ) . toHaveBeenCalled ( ) ;
184189 } ) ;
185190 } ) ;
186191
@@ -198,7 +203,6 @@ describe('DeleteComColPageComponent', () => {
198203
199204 it ( 'should redirect to the edit page' , ( ) => {
200205 const redirectURL = frontendURL + '/' + validUUID + '/edit' ;
201- spyOn ( router , 'navigate' ) ;
202206 comp . onCancel ( data1 ) ;
203207 fixture . detectChanges ( ) ;
204208 expect ( router . navigate ) . toHaveBeenCalledWith ( [ redirectURL ] ) ;
0 commit comments