@@ -8,7 +8,10 @@ import {
88 TestBed ,
99 waitForAsync ,
1010} from '@angular/core/testing' ;
11+ import { By } from '@angular/platform-browser' ;
1112import { Router } from '@angular/router' ;
13+ import { APP_CONFIG } from '@dspace/config/app-config.interface' ;
14+ import { ImportExternalMetadataViewMode } from '@dspace/config/import-external-metadata-view.mode' ;
1215import { NotificationsService } from '@dspace/core/notification-system/notifications.service' ;
1316import { ExternalSourceEntry } from '@dspace/core/shared/external-source-entry.model' ;
1417import { Metadata } from '@dspace/core/shared/metadata.utils' ;
@@ -25,6 +28,7 @@ import { getTestScheduler } from 'jasmine-marbles';
2528import { of } from 'rxjs' ;
2629import { TestScheduler } from 'rxjs/testing' ;
2730
31+ import { environment } from '../../../../environments/environment.test' ;
2832import { CollectionListEntry } from '../../../shared/collection-dropdown/collection-dropdown.component' ;
2933import { SubmissionService } from '../../submission.service' ;
3034import { SubmissionImportExternalCollectionComponent } from '../import-external-collection/submission-import-external-collection.component' ;
@@ -68,6 +72,7 @@ describe('SubmissionImportExternalPreviewComponent test suite', () => {
6872 { provide : NotificationsService , useValue : new NotificationsServiceStub ( ) } ,
6973 { provide : NgbModal , useValue : ngbModal } ,
7074 { provide : NgbActiveModal , useValue : ngbActiveModal } ,
75+ { provide : APP_CONFIG , useValue : environment } ,
7176 SubmissionImportExternalPreviewComponent ,
7277 ] ,
7378 schemas : [ NO_ERRORS_SCHEMA ] ,
@@ -118,6 +123,7 @@ describe('SubmissionImportExternalPreviewComponent test suite', () => {
118123 fixture . detectChanges ( ) ;
119124
120125 expect ( comp . metadataList ) . toEqual ( expected ) ;
126+ expect ( comp . viewMode ) . toEqual ( environment . submission . importExternal . viewMode ) ;
121127 } ) ;
122128
123129 it ( 'Should close the modal calling \'activeModal.dismiss\'' , ( ) => {
@@ -165,6 +171,61 @@ describe('SubmissionImportExternalPreviewComponent test suite', () => {
165171 done ( ) ;
166172 } ) ;
167173 } ) ;
174+
175+ describe ( 'Metadatafield View Modes UI rendering' , ( ) => {
176+ beforeEach ( ( ) => {
177+ fixture = TestBed . createComponent ( SubmissionImportExternalPreviewComponent ) ;
178+ comp = fixture . componentInstance ;
179+ comp . externalSourceEntry = externalEntry ;
180+ fixture . detectChanges ( ) ;
181+ } ) ;
182+
183+ it ( 'should display tooltip only in Tooltip mode' , ( ) => {
184+ comp . viewMode = ImportExternalMetadataViewMode . Tooltip ;
185+ fixture . detectChanges ( ) ;
186+
187+ const tooltipIcon = fixture . debugElement . query ( By . css ( '.fa-info-circle' ) ) ;
188+ const labelText = fixture . debugElement . query ( By . css ( 'span.text-muted' ) ) ;
189+
190+ expect ( tooltipIcon ) . toBeTruthy ( ) ;
191+ expect ( labelText ) . toBeNull ( ) ;
192+ } ) ;
193+
194+ it ( 'should display label only in Labeled mode' , ( ) => {
195+ comp . viewMode = ImportExternalMetadataViewMode . Labeled ;
196+ fixture . detectChanges ( ) ;
197+
198+ const tooltipIcon = fixture . debugElement . query ( By . css ( '.fa-info-circle' ) ) ;
199+ const labelText = fixture . debugElement . query ( By . css ( 'span.text-muted' ) ) ;
200+
201+ expect ( tooltipIcon ) . toBeNull ( ) ;
202+ expect ( labelText ) . toBeTruthy ( ) ;
203+ expect ( labelText . nativeElement . textContent ) . toContain ( '(dc.identifier.uri)' ) ;
204+ } ) ;
205+
206+ it ( 'should display both in Full mode' , ( ) => {
207+ comp . viewMode = ImportExternalMetadataViewMode . Full ;
208+ fixture . detectChanges ( ) ;
209+
210+ const tooltipIcon = fixture . debugElement . query ( By . css ( '.fa-info-circle' ) ) ;
211+ const labelText = fixture . debugElement . query ( By . css ( 'span.text-muted' ) ) ;
212+
213+ expect ( tooltipIcon ) . toBeTruthy ( ) ;
214+ expect ( labelText ) . toBeTruthy ( ) ;
215+ expect ( labelText . nativeElement . textContent ) . toContain ( '(dc.identifier.uri)' ) ;
216+ } ) ;
217+
218+ it ( 'should display neither in Disable mode' , ( ) => {
219+ comp . viewMode = ImportExternalMetadataViewMode . Disable ;
220+ fixture . detectChanges ( ) ;
221+
222+ const tooltipIcon = fixture . debugElement . query ( By . css ( '.fa-info-circle' ) ) ;
223+ const labelText = fixture . debugElement . query ( By . css ( 'span.text-muted' ) ) ;
224+
225+ expect ( tooltipIcon ) . toBeNull ( ) ;
226+ expect ( labelText ) . toBeNull ( ) ;
227+ } ) ;
228+ } ) ;
168229} ) ;
169230
170231// declare a test component
0 commit comments