Component https://github.com/valor-software/ngx-bootstrap .
in the template I have:
<span dropdown placement="bottom right">
<a id="droplist-label" href="javascript:void(0)" dropdownToggle>
<span>{{conf.title}}</span>
</a>
<ul class="dropdown-menu pull-right" *dropdownMenu>
<li *ngFor="let item of items">
<a class="dropdown-item" (click)="listClick(item.value)" href="javascript:void(0)">{{item.label}}</a>
</li>
</ul>
</span>
The street is not added until the tag is clicked - therefore, I cannot access it in the test.
Call:
let droplist = fixture.debugElement.query(By.css('#droplist-label')).nativeElement;
droplist.click();
Doesn't work - if I try to search dropdown-menu, it is empty:
it('should test if droplist has title', async(() => {
fixture.detectChanges();
let droplist = fixture.debugElement.query(By.css('#droplist-label')).nativeElement;
droplist.click();
fixture.whenStable().then(() => {
let droplistOptions = fixture.debugElement.queryAll(By.css('.dropdown-item'));
expect(droplistOptions.length).toBeGreaterThan(0);
});
}));
The directive has a hostlistener for the click event, which seems to be - how can I call it so that ul becomes available?
source
share