Skip to content

Commit cc64187

Browse files
committed
test(dropdown): use provided in open method target
1 parent 1a19cde commit cc64187

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

projects/igniteui-angular/src/lib/drop-down/drop-down.component.spec.ts

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,6 @@ describe('IgxDropDown ', () => {
256256
expect(positionStrategy.settings.horizontalDirection).toBe(HorizontalAlignment.Right);
257257
expect(positionStrategy.settings.verticalDirection).toBe(VerticalAlignment.Bottom);
258258
});
259-
260259
it('should apply custom overlay settings if provided', () => {
261260
const toggle: IgxToggleDirective = (dropdown as any).toggleDirective;
262261
const customOverlaySettings: OverlaySettings = {
@@ -1266,6 +1265,31 @@ describe('IgxDropDown ', () => {
12661265
expect(dropdown.closing.emit).toHaveBeenCalledTimes(3);
12671266
expect(dropdown.closed.emit).toHaveBeenCalledTimes(3);
12681267
}));
1268+
fit('#15137 - should bind to custom target if provided', fakeAsync(() => {
1269+
const input = fixture.debugElement.query(By.css('input'));
1270+
dropdown.open({ target: input.nativeElement });
1271+
tick();
1272+
fixture.detectChanges();
1273+
1274+
const dropdownItems = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_ITEM}`));
1275+
expect(dropdownItems).not.toBeUndefined();
1276+
1277+
const inputRect = input.nativeElement.getBoundingClientRect();
1278+
let dropdownRect = dropdownItems[0].nativeElement.getBoundingClientRect();
1279+
expect(dropdownRect.left).toBe(inputRect.left);
1280+
expect(dropdownRect.top).toBe(inputRect.bottom);
1281+
1282+
dropdown.close();
1283+
tick();
1284+
fixture.detectChanges();
1285+
dropdown.open();
1286+
tick();
1287+
fixture.detectChanges();
1288+
1289+
dropdownRect = dropdownItems[0].nativeElement.getBoundingClientRect();
1290+
expect(dropdownRect.left).toBe(0);
1291+
expect(dropdownRect.top).toBe(0);
1292+
}));
12691293
});
12701294
});
12711295
});
@@ -1341,7 +1365,6 @@ class DoubleIgxDropDownComponent implements OnInit {
13411365
}
13421366
}
13431367
}
1344-
13451368
@Component({
13461369
template: `
13471370
<input (click)="toggleDropDown()">

0 commit comments

Comments
 (0)