mirror of
https://github.com/DSpace/dspace-angular.git
synced 2025-10-13 13:03:04 +00:00
Merge branch 'w2p-55962_hide-metadata-labels-without-value' into entities-master
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<div class="simple-view-element">
|
||||
<span *ngIf="content.children.length != 0">
|
||||
<h5 class="simple-view-element-header" *ngIf="label">{{ label }}</h5>
|
||||
<div class="simple-view-element-body">
|
||||
<ng-content></ng-content>
|
||||
</div>
|
||||
</span>
|
||||
<div #content class="simple-view-element-body">
|
||||
<ng-content></ng-content>
|
||||
</div>
|
||||
</div>
|
||||
|
@@ -0,0 +1,54 @@
|
||||
import { ComponentFixture, TestBed, async } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { Component, DebugElement } from '@angular/core';
|
||||
|
||||
import { MetadataFieldWrapperComponent } from './metadata-field-wrapper.component';
|
||||
|
||||
@Component({
|
||||
selector: 'ds-component-with-content',
|
||||
template: '<ds-metadata-field-wrapper [label]="\'test label\'">\n' +
|
||||
' <div class="my content">\n' +
|
||||
' </div>\n' +
|
||||
'</ds-metadata-field-wrapper>'
|
||||
})
|
||||
class ContentComponent {}
|
||||
|
||||
describe('MetadataFieldWrapperComponent', () => {
|
||||
let component: MetadataFieldWrapperComponent;
|
||||
let fixture: ComponentFixture<MetadataFieldWrapperComponent>;
|
||||
|
||||
beforeEach(async(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [MetadataFieldWrapperComponent, ContentComponent]
|
||||
}).compileComponents();
|
||||
}));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MetadataFieldWrapperComponent);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
const wrapperSelector = '.simple-view-element';
|
||||
const labelSelector = '.simple-view-element-header';
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not show a label when there is no content', () => {
|
||||
component.label = 'test label';
|
||||
fixture.detectChanges();
|
||||
const debugLabel = fixture.debugElement.query(By.css(labelSelector));
|
||||
expect(debugLabel).toBeNull();
|
||||
});
|
||||
|
||||
it('should show a label when there is content', () => {
|
||||
const parentFixture = TestBed.createComponent(ContentComponent);
|
||||
parentFixture.detectChanges();
|
||||
const parentComponent = parentFixture.componentInstance;
|
||||
const parentNative = parentFixture.nativeElement;
|
||||
const nativeLabel = parentNative.querySelector(labelSelector);
|
||||
expect(nativeLabel.textContent).toContain('test label');
|
||||
});
|
||||
|
||||
});
|
@@ -1,4 +1,5 @@
|
||||
import { Component, Input } from '@angular/core';
|
||||
import { Metadatum } from '../../../core/shared/metadatum.model';
|
||||
|
||||
/**
|
||||
* This component renders the configured 'values' into the ds-metadata-field-wrapper component.
|
||||
@@ -11,7 +12,7 @@ import { Component, Input } from '@angular/core';
|
||||
})
|
||||
export class MetadataValuesComponent {
|
||||
|
||||
@Input() values: any;
|
||||
@Input() values: Metadatum[];
|
||||
|
||||
@Input() separator: string;
|
||||
|
||||
|
Reference in New Issue
Block a user