Skip to content

Commit 6fd36bd

Browse files
committed
Geospatial maps: Test fixes
Including reverting a nice-to-have improvement to 'hasNoContent' for field wrapper and non-text content.
1 parent d5c3f4d commit 6fd36bd

4 files changed

Lines changed: 17 additions & 13 deletions

File tree

src/app/browse-by/browse-by-geospatial-data/browse-by-geospatial-data.component.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const mockPointValues = createSuccessfulRemoteDataObject$(buildPaginatedList(new
6767
const expectedSearchOptions: PaginatedSearchOptions = Object.assign({
6868
'configuration': environment.geospatialMapViewer.spatialFacetDiscoveryConfiguration,
6969
'scope': scope,
70+
'facetLimit': 99999,
7071
});
7172

7273
// Mock search config service returns mock search filter config on getConfig()

src/app/item-page/simple/field-components/specific-field/geospatial/geospatial-item-page-field.component.spec.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,20 @@ import {
77
TestBed,
88
waitForAsync,
99
} from '@angular/core/testing';
10+
import { Store } from '@ngrx/store';
11+
import { MockStore } from '@ngrx/store/testing';
1012
import {
1113
TranslateLoader,
1214
TranslateModule,
1315
} from '@ngx-translate/core';
1416

15-
import { APP_CONFIG } from '../../../../../../config/app-config.interface';
17+
import {
18+
APP_CONFIG,
19+
APP_DATA_SERVICES_MAP,
20+
} from '../../../../../../config/app-config.interface';
1621
import { environment } from '../../../../../../environments/environment';
1722
import { BrowseDefinitionDataService } from '../../../../../core/browse/browse-definition-data.service';
23+
import { ITEM } from '../../../../../core/shared/item.resource-type';
1824
import { BrowseDefinitionDataServiceStub } from '../../../../../shared/testing/browse-definition-data-service.stub';
1925
import { TranslateLoaderMock } from '../../../../../shared/testing/translate-loader.mock';
2026
import { MetadataValuesComponent } from '../../../../field-components/metadata-values/metadata-values.component';
@@ -29,6 +35,9 @@ const mockField = 'dcterms.spatial';
2935
const mockLabel = 'Test location';
3036
const mockFields = [mockField];
3137

38+
const mockDataServiceMap: any = new Map([
39+
[ITEM.value, () => import('../../../../../shared/testing/test-data-service.mock').then(m => m.TestDataService)],
40+
]);
3241
describe('GeospatialItemPageFieldComponent', () => {
3342
beforeEach(waitForAsync(() => {
3443
TestBed.configureTestingModule({
@@ -41,6 +50,8 @@ describe('GeospatialItemPageFieldComponent', () => {
4150
providers: [
4251
{ provide: APP_CONFIG, useValue: environment },
4352
{ provide: BrowseDefinitionDataService, useValue: BrowseDefinitionDataServiceStub },
53+
{ provide: Store, useValue: MockStore },
54+
{ provide: APP_DATA_SERVICES_MAP, useValue: mockDataServiceMap },
4455
],
4556
schemas: [NO_ERRORS_SCHEMA],
4657
}).overrideComponent(GeospatialItemPageFieldComponent, {
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
<div class="simple-view-element" [class.d-none]="hideIfNoTextContent && hasNoContent">
1+
<div class="simple-view-element" [class.d-none]="hideIfNoTextContent && content.textContent.trim().length === 0">
22
@if (label) {
33
<h2 class="simple-view-element-header">{{ label }}</h2>
4-
<div #content class="simple-view-element-body">
5-
<ng-content></ng-content>
6-
</div>
74
}
5+
<div #content class="simple-view-element-body">
6+
<ng-content></ng-content>
7+
</div>
88
</div>

src/app/shared/metadata-field-wrapper/metadata-field-wrapper.component.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11

22
import {
33
Component,
4-
ElementRef,
54
Input,
6-
ViewChild,
75
} from '@angular/core';
86

97
/**
@@ -23,12 +21,6 @@ export class MetadataFieldWrapperComponent {
2321
* The label (title) for the content
2422
*/
2523
@Input() label: string;
26-
@ViewChild('content', { static: true }) contentElementRef: ElementRef;
2724

2825
@Input() hideIfNoTextContent = true;
29-
30-
get hasNoContent(): boolean{
31-
return this.contentElementRef.nativeElement.textContent.trim().length === 0
32-
&& this.contentElementRef.nativeElement.querySelector('img') === null;
33-
}
3426
}

0 commit comments

Comments
 (0)