@@ -15,6 +15,7 @@ import { By } from '@angular/platform-browser';
1515import { ConfigurationDataService } from '../core/data/configuration-data.service' ;
1616import { ConfigurationProperty } from '../core/shared/configuration-property.model' ;
1717import { getProcessDetailRoute } from '../process-page/process-page-routing.paths' ;
18+ import { HandleService } from '../shared/handle.service' ;
1819
1920describe ( 'CurationFormComponent' , ( ) => {
2021 let comp : CurationFormComponent ;
@@ -23,6 +24,7 @@ describe('CurationFormComponent', () => {
2324 let scriptDataService : ScriptDataService ;
2425 let processDataService : ProcessDataService ;
2526 let configurationDataService : ConfigurationDataService ;
27+ let handleService : HandleService ;
2628 let notificationsService ;
2729 let router ;
2830
@@ -51,18 +53,23 @@ describe('CurationFormComponent', () => {
5153 } ) )
5254 } ) ;
5355
56+ handleService = {
57+ normalizeHandle : ( a ) => a
58+ } as any ;
59+
5460 notificationsService = new NotificationsServiceStub ( ) ;
5561 router = new RouterStub ( ) ;
5662
5763 TestBed . configureTestingModule ( {
5864 imports : [ TranslateModule . forRoot ( ) , FormsModule , ReactiveFormsModule ] ,
5965 declarations : [ CurationFormComponent ] ,
6066 providers : [
61- { provide : ScriptDataService , useValue : scriptDataService } ,
62- { provide : ProcessDataService , useValue : processDataService } ,
63- { provide : NotificationsService , useValue : notificationsService } ,
64- { provide : Router , useValue : router } ,
65- { provide : ConfigurationDataService , useValue : configurationDataService } ,
67+ { provide : ScriptDataService , useValue : scriptDataService } ,
68+ { provide : ProcessDataService , useValue : processDataService } ,
69+ { provide : NotificationsService , useValue : notificationsService } ,
70+ { provide : HandleService , useValue : handleService } ,
71+ { provide : Router , useValue : router } ,
72+ { provide : ConfigurationDataService , useValue : configurationDataService } ,
6673 ] ,
6774 schemas : [ CUSTOM_ELEMENTS_SCHEMA ]
6875 } ) . compileComponents ( ) ;
@@ -143,4 +150,13 @@ describe('CurationFormComponent', () => {
143150 { name : '-i' , value : 'all' } ,
144151 ] , [ ] ) ;
145152 } ) ;
153+
154+ it ( `should show an error notification and return when an invalid dsoHandle is provided` , ( ) => {
155+ comp . dsoHandle = 'test-handle' ;
156+ spyOn ( handleService , 'normalizeHandle' ) . and . returnValue ( null ) ;
157+ comp . submit ( ) ;
158+
159+ expect ( notificationsService . error ) . toHaveBeenCalled ( ) ;
160+ expect ( scriptDataService . invoke ) . not . toHaveBeenCalled ( ) ;
161+ } ) ;
146162} ) ;
0 commit comments