Skip to content

Commit

Permalink
test(dropdown): use provided in open method target
Browse files Browse the repository at this point in the history
  • Loading branch information
wnvko committed Jan 22, 2025
1 parent 32a5e77 commit ce10505
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ describe('IgxDropDown ', () => {
expect(positionStrategy.settings.horizontalDirection).toBe(HorizontalAlignment.Right);
expect(positionStrategy.settings.verticalDirection).toBe(VerticalAlignment.Bottom);
});

it('should apply custom overlay settings if provided', () => {
const toggle: IgxToggleDirective = (dropdown as any).toggleDirective;
const customOverlaySettings: OverlaySettings = {
Expand Down Expand Up @@ -1266,6 +1265,31 @@ describe('IgxDropDown ', () => {
expect(dropdown.closing.emit).toHaveBeenCalledTimes(3);
expect(dropdown.closed.emit).toHaveBeenCalledTimes(3);
}));
fit('#15137 - should bind to custom target if provided', fakeAsync(() => {
const input = fixture.debugElement.query(By.css('input'));
dropdown.open({ target: input.nativeElement });
tick();
fixture.detectChanges();

const dropdownItems = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_ITEM}`));
expect(dropdownItems).not.toBeUndefined();

const inputRect = input.nativeElement.getBoundingClientRect();
let dropdownRect = dropdownItems[0].nativeElement.getBoundingClientRect();
expect(dropdownRect.left).toBe(inputRect.left);
expect(dropdownRect.top).toBe(inputRect.bottom);

dropdown.close();
tick();
fixture.detectChanges();
dropdown.open();
tick();
fixture.detectChanges();

dropdownRect = dropdownItems[0].nativeElement.getBoundingClientRect();
expect(dropdownRect.left).toBe(0);
expect(dropdownRect.top).toBe(0);
}));
});
});
});
Expand Down Expand Up @@ -1341,7 +1365,6 @@ class DoubleIgxDropDownComponent implements OnInit {
}
}
}

@Component({
template: `
<input (click)="toggleDropDown()">
Expand Down

0 comments on commit ce10505

Please sign in to comment.