@@ -10,10 +10,7 @@ import { By } from '@angular/platform-browser'
10
10
import { SourcesService } from '@geonetwork-ui/feature/catalog'
11
11
import { MapManagerService } from '@geonetwork-ui/feature/map'
12
12
import { SearchService } from '@geonetwork-ui/feature/search'
13
- import {
14
- ErrorType ,
15
- SearchResultsErrorComponent ,
16
- } from '@geonetwork-ui/ui/elements'
13
+ import { ErrorComponent , ErrorType } from '@geonetwork-ui/ui/elements'
17
14
import { TranslateModule } from '@ngx-translate/core'
18
15
import { BehaviorSubject , of } from 'rxjs'
19
16
import { RecordMetadataComponent } from './record-metadata.component'
@@ -168,7 +165,7 @@ describe('RecordMetadataComponent', () => {
168
165
MockDataOtherlinksComponent ,
169
166
MockDataApisComponent ,
170
167
MockRelatedComponent ,
171
- SearchResultsErrorComponent ,
168
+ ErrorComponent ,
172
169
MockMetadataInfoComponent ,
173
170
MockMetadataContactComponent ,
174
171
MockRecordApiFormComponent ,
@@ -598,9 +595,9 @@ describe('RecordMetadataComponent', () => {
598
595
describe ( 'error handling' , ( ) => {
599
596
describe ( 'normal' , ( ) => {
600
597
it ( 'does not show errors' , ( ) => {
601
- const result = fixture . debugElement . query (
602
- By . directive ( SearchResultsErrorComponent )
603
- )
598
+ facade . otherLinks$ . next ( [ '' ] )
599
+ fixture . detectChanges ( )
600
+ const result = fixture . debugElement . query ( By . directive ( ErrorComponent ) )
604
601
expect ( result ) . toBeFalsy ( )
605
602
} )
606
603
} )
@@ -610,9 +607,7 @@ describe('RecordMetadataComponent', () => {
610
607
fixture . detectChanges ( )
611
608
} )
612
609
it ( 'shows error' , ( ) => {
613
- const result = fixture . debugElement . query (
614
- By . directive ( SearchResultsErrorComponent )
615
- )
610
+ const result = fixture . debugElement . query ( By . directive ( ErrorComponent ) )
616
611
617
612
expect ( result ) . toBeTruthy ( )
618
613
expect ( result . componentInstance . type ) . toBe ( ErrorType . RECORD_NOT_FOUND )
@@ -628,14 +623,30 @@ describe('RecordMetadataComponent', () => {
628
623
fixture . detectChanges ( )
629
624
} )
630
625
it ( 'shows error' , ( ) => {
631
- const result = fixture . debugElement . query (
632
- By . directive ( SearchResultsErrorComponent )
633
- )
626
+ const result = fixture . debugElement . query ( By . directive ( ErrorComponent ) )
634
627
635
628
expect ( result ) . toBeTruthy ( )
636
629
expect ( result . componentInstance . type ) . toBe ( ErrorType . RECEIVED_ERROR )
637
630
expect ( result . componentInstance . error ) . toBe ( 'This is an Error!' )
638
631
} )
639
632
} )
633
+
634
+ describe ( 'When there are no link (download, api or other links)' , ( ) => {
635
+ beforeEach ( ( ) => {
636
+ facade . apiLinks$ . next ( [ ] )
637
+ facade . downloadLinks$ . next ( [ ] )
638
+ facade . otherLinks$ . next ( [ ] )
639
+ fixture . detectChanges ( )
640
+ } )
641
+ it ( 'shows the no link error block' , ( ) => {
642
+ const result = fixture . debugElement . query (
643
+ By . css ( '[data-test="dataset-has-no-link-block"]' )
644
+ )
645
+ expect ( result ) . toBeTruthy ( )
646
+ expect ( result . componentInstance . type ) . toBe (
647
+ ErrorType . DATASET_HAS_NO_LINK
648
+ )
649
+ } )
650
+ } )
640
651
} )
641
652
} )
0 commit comments