mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2026-09-02 17:53:30 +00:00
[ACS-9106] Make the descendants false iin data column component (#12077)
* [ACS-9106] Make the descendants false iin data column component * [ACS-9106] Add unit test * [ACS-9106] Fix formatting * [ACS-9106] Remove the declaration of fixture outside it
This commit is contained in:
@@ -15,9 +15,39 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Component, ViewChild } from '@angular/core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { DataColumnComponent } from './data-column.component';
|
||||
|
||||
describe('DataColumnListComponent', () => {
|
||||
@Component({
|
||||
imports: [DataColumnComponent],
|
||||
template: `
|
||||
<data-column key="name">
|
||||
<ng-template />
|
||||
</data-column>
|
||||
`
|
||||
})
|
||||
class DirectTemplateHostComponent {
|
||||
@ViewChild(DataColumnComponent)
|
||||
dataColumn: DataColumnComponent;
|
||||
}
|
||||
|
||||
@Component({
|
||||
imports: [DataColumnComponent],
|
||||
template: `
|
||||
<data-column key="name">
|
||||
<div>
|
||||
<ng-template />
|
||||
</div>
|
||||
</data-column>
|
||||
`
|
||||
})
|
||||
class NestedTemplateHostComponent {
|
||||
@ViewChild(DataColumnComponent)
|
||||
dataColumn: DataColumnComponent;
|
||||
}
|
||||
|
||||
describe('DataColumnComponent', () => {
|
||||
it('should setup screen reader title for thumbnails', () => {
|
||||
const component = new DataColumnComponent();
|
||||
component.key = '$thumbnail';
|
||||
@@ -25,4 +55,20 @@ describe('DataColumnListComponent', () => {
|
||||
component.ngOnInit();
|
||||
expect(component.srTitle).toBeTruthy();
|
||||
});
|
||||
|
||||
describe('template ContentChild selection', () => {
|
||||
it('should capture a direct ng-template child', () => {
|
||||
const directFixture = TestBed.createComponent(DirectTemplateHostComponent);
|
||||
directFixture.detectChanges();
|
||||
|
||||
expect(directFixture.componentInstance.dataColumn.template).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not capture a nested descendant ng-template', () => {
|
||||
const nestedFixture = TestBed.createComponent(NestedTemplateHostComponent);
|
||||
nestedFixture.detectChanges();
|
||||
|
||||
expect(nestedFixture.componentInstance.dataColumn.template).toBeFalsy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -78,7 +78,7 @@ export class DataColumnComponent implements OnInit {
|
||||
@Input()
|
||||
subtitle: string = '';
|
||||
|
||||
@ContentChild(TemplateRef)
|
||||
@ContentChild(TemplateRef, { descendants: false })
|
||||
template: any;
|
||||
|
||||
/** Custom tooltip formatter function. */
|
||||
|
||||
Reference in New Issue
Block a user