@@ -175,12 +175,12 @@ describe('DsDynamicOneboxComponent test suite', () => {
175175 providers : [
176176 ChangeDetectorRef ,
177177 DsDynamicOneboxComponent ,
178- { provide : VocabularyService , useValue : vocabularyServiceStub } ,
179- { provide : DynamicFormLayoutService , useValue : mockDynamicFormLayoutService } ,
180- { provide : DynamicFormValidationService , useValue : mockDynamicFormValidationService } ,
181- { provide : NgbModal , useValue : modal } ,
182- { provide : FormBuilderService } ,
183- { provide : SubmissionService , useClass : SubmissionServiceStub }
178+ { provide : VocabularyService , useValue : vocabularyServiceStub } ,
179+ { provide : DynamicFormLayoutService , useValue : mockDynamicFormLayoutService } ,
180+ { provide : DynamicFormValidationService , useValue : mockDynamicFormValidationService } ,
181+ { provide : NgbModal , useValue : modal } ,
182+ { provide : FormBuilderService } ,
183+ { provide : SubmissionService , useClass : SubmissionServiceStub }
184184 ] ,
185185 schemas : [ CUSTOM_ELEMENTS_SCHEMA ]
186186 } ) . compileComponents ( ) ;
@@ -348,7 +348,7 @@ describe('DsDynamicOneboxComponent test suite', () => {
348348 } ) ) ;
349349 spyOn ( ( oneboxComponent as any ) . vocabularyService , 'getVocabularyEntryByValue' ) . and . returnValue ( entry ) ;
350350 spyOn ( ( oneboxComponent as any ) . vocabularyService , 'getVocabularyEntryByID' ) . and . returnValue ( entry ) ;
351- ( oneboxComponent . model as any ) . value = new FormFieldMetadataValueObject ( 'test' , null , null , null , 'testDisplay' ) ;
351+ ( oneboxComponent . model as any ) . value = new FormFieldMetadataValueObject ( 'test' , null , null , null , 'testDisplay' ) ;
352352 oneboxCompFixture . detectChanges ( ) ;
353353 } ) ;
354354
@@ -359,7 +359,7 @@ describe('DsDynamicOneboxComponent test suite', () => {
359359
360360 it ( 'should init component properly' , fakeAsync ( ( ) => {
361361 tick ( ) ;
362- expect ( oneboxComponent . currentValue ) . toEqual ( new FormFieldMetadataValueObject ( 'test' , null , null , null , 'testDisplay' ) ) ;
362+ expect ( oneboxComponent . currentValue ) . toEqual ( new FormFieldMetadataValueObject ( 'test' , null , null , null , 'testDisplay' ) ) ;
363363 expect ( ( oneboxComponent as any ) . vocabularyService . getVocabularyEntryByValue ) . not . toHaveBeenCalled ( ) ;
364364 } ) ) ;
365365
@@ -396,7 +396,7 @@ describe('DsDynamicOneboxComponent test suite', () => {
396396
397397 it ( 'should init component properly' , fakeAsync ( ( ) => {
398398 tick ( ) ;
399- expect ( oneboxComponent . currentValue ) . toEqual ( new FormFieldMetadataValueObject ( 'test' , null , null , validAuthority , 'test' ) ) ;
399+ expect ( oneboxComponent . currentValue ) . toEqual ( new FormFieldMetadataValueObject ( 'test' , null , null , validAuthority , 'test' ) ) ;
400400 expect ( ( oneboxComponent as any ) . vocabularyService . getVocabularyEntryByID ) . not . toHaveBeenCalled ( ) ;
401401 } ) ) ;
402402
@@ -457,7 +457,7 @@ describe('DsDynamicOneboxComponent test suite', () => {
457457 } ) ) ;
458458 spyOn ( ( oneboxComponent as any ) . vocabularyService , 'getVocabularyEntryByValue' ) . and . returnValue ( entry ) ;
459459 spyOn ( ( oneboxComponent as any ) . vocabularyService , 'getVocabularyEntryByID' ) . and . returnValue ( entry ) ;
460- ( oneboxComponent . model as any ) . value = new FormFieldMetadataValueObject ( 'test' , null , null , null , 'testDisplay' ) ;
460+ ( oneboxComponent . model as any ) . value = new FormFieldMetadataValueObject ( 'test' , null , null , null , 'testDisplay' ) ;
461461 oneboxCompFixture . detectChanges ( ) ;
462462 } ) ;
463463
@@ -468,7 +468,7 @@ describe('DsDynamicOneboxComponent test suite', () => {
468468
469469 it ( 'should init component properly' , fakeAsync ( ( ) => {
470470 tick ( ) ;
471- expect ( oneboxComponent . currentValue ) . toEqual ( new FormFieldMetadataValueObject ( 'test' , null , null , null , 'testDisplay' ) ) ;
471+ expect ( oneboxComponent . currentValue ) . toEqual ( new FormFieldMetadataValueObject ( 'test' , null , null , null , 'testDisplay' ) ) ;
472472 expect ( ( oneboxComponent as any ) . vocabularyService . getVocabularyEntryByValue ) . toHaveBeenCalled ( ) ;
473473 } ) ) ;
474474
@@ -517,6 +517,38 @@ describe('DsDynamicOneboxComponent test suite', () => {
517517 } ) ) ;
518518 } ) ;
519519
520+ describe ( 'selectAlternativeInformation' , ( ) => {
521+ beforeEach ( ( ) => {
522+ oneboxCompFixture = TestBed . createComponent ( DsDynamicOneboxComponent ) ;
523+ debugElement = oneboxCompFixture . debugElement ;
524+ oneboxComponent = oneboxCompFixture . componentInstance ;
525+ oneboxComponent . currentValue = new FormFieldMetadataValueObject ( 'test' , null , null , null , 'testDisplay' ) ;
526+ oneboxComponent . model = new DynamicOneboxModel ( ONEBOX_TEST_MODEL_CONFIG ) ;
527+
528+ spyOn ( oneboxComponent , 'onSelectItem' ) . and . returnValue ( undefined ) ;
529+ spyOn ( oneboxComponent , 'toggleOtherInfoSelection' ) . and . returnValue ( undefined ) ;
530+ } ) ;
531+
532+ it ( 'sets authority when unformattedOtherInfoValue contains "::"' , ( ) => {
533+ const info = 'testInfo' ;
534+ const unformattedItem = 'testInfo::authorityValue' ;
535+ oneboxComponent . otherInfoValuesUnformatted = [ unformattedItem ] ;
536+
537+ oneboxComponent . selectAlternativeInfo ( info ) ;
538+
539+ expect ( oneboxComponent . currentValue . authority ) . toBe ( 'authorityValue' ) ;
540+ } ) ;
541+
542+ it ( 'sets authority to undefined when unformattedOtherInfoValue does not contain "::"' , ( ) => {
543+ const info = 'testInfo' ;
544+ const unformattedItem = 'testInfo' ;
545+ oneboxComponent . otherInfoValuesUnformatted = [ unformattedItem ] ;
546+
547+ oneboxComponent . selectAlternativeInfo ( info ) ;
548+
549+ expect ( oneboxComponent . currentValue . authority ) . toBeUndefined ( ) ;
550+ } ) ;
551+ } ) ;
520552 } ) ;
521553} ) ;
522554
0 commit comments