I am testing a component that has a query list of @ContentChildren
. In my component these are accessible in the 'AfterContentInit` life cycle hook. But, when i intend to access the same in my spec file, my query list return me with an empty arrays.
I am trying to test the component without creating any mock component as it is done in this link. I have tried the solution provided in the link below but that didn't work for me.
Angular 2 unit testing - @ViewChild is undefined
In my Component:
@ContentChildren(GetTemplateDirective) public templates: QueryList<GetTemplateDirective<AccordionTemplate>>;
In the component's spec file:
it('should show the custom icon when the external template is passed', async(function () {
accordionFixture.detectChanges();
accordionComponent.ngAfterContentInit();
console.log(accordionComponent.templates);
expect(component.templates.toArray().length).toBeGreaterThan(0);
}));