I've been attempting to test the dropdown-toggle functionality, but I haven't been successful in getting it to work. I've already included BsDropdownModule
in the spec file.
Note: My project is using ngx-bootstrap.
Here's the code snippet that I've experimented with:
HTML:
<div class="btnBox" dropdown placement="bottom right">
<button class="btnIcon dropdown-toggle" dropdownToggle>
</button>
<ul class="btnOptionBox dropdown-menu dropdown-menu-right" *dropdownMenu>
<li class="iconBtn" (click)="someFun()" type="button"><span>Edit</span></li>
<li class="iconBtn" (click)="someFun1()" type="button"><span>Delete</span></li>
</ul>
</div>
Test Spec:
it("When toggle option is clicked, options should be displayed",() => {
fixture.detectChanges();
let toggleButton = fixture.debugElement.queryAll(By.css('[dropdownToggle]'));
toggleButton[0].nativeElement.click();
fixture.detectChanges();
/*Unable to access li tag directly. Hence, I'm referencing its parent*/
let list = fixture.debugElement.queryAll(By.css('div.ellipsisBox'));
console.log(list[0]); /*Displays the list within the children array*/
console.log(list[0].children); /*Doesn't display the list*/
});
Could someone provide guidance on the correct approach to achieve this?