Skip to content

Commit 41b041b

Browse files
committed
test(overlay): Add new test #8184
for excludeFromOutsideClick.
1 parent 0c081f8 commit 41b041b

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed

projects/igniteui-angular/src/lib/services/overlay/overlay.spec.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3614,6 +3614,55 @@ describe('igxOverlay', () => {
36143614
});
36153615
}));
36163616

3617+
it('Should remain opened when click is on an element contained in the excludeFromOutsideClick collection', fakeAsync(async () => {
3618+
const fixture = TestBed.createComponent(EmptyPageComponent);
3619+
fixture.detectChanges();
3620+
3621+
const overlay = fixture.componentInstance.overlay;
3622+
const divElement = fixture.componentInstance.divElement.nativeElement as HTMLElement;
3623+
const overlaySettings: OverlaySettings = {
3624+
modal: false,
3625+
closeOnOutsideClick: true,
3626+
positionStrategy: new GlobalPositionStrategy(),
3627+
excludeFromOutsideClick: [divElement]
3628+
};
3629+
3630+
spyOn(overlay, 'show').and.callThrough();
3631+
spyOn(overlay.onClosing, 'emit');
3632+
spyOn(overlay.onClosed, 'emit');
3633+
3634+
overlay.show(overlay.attach(SimpleDynamicComponent), overlaySettings);
3635+
tick();
3636+
expect(overlay.show).toHaveBeenCalledTimes(1);
3637+
3638+
divElement.click();
3639+
tick();
3640+
3641+
expect(overlay.onClosing.emit).toHaveBeenCalledTimes(0);
3642+
expect(overlay.onClosed.emit).toHaveBeenCalledTimes(0);
3643+
3644+
overlay.hideAll();
3645+
tick();
3646+
expect(overlay.onClosing.emit).toHaveBeenCalledTimes(1);
3647+
expect(overlay.onClosed.emit).toHaveBeenCalledTimes(1);
3648+
3649+
overlaySettings.excludeFromOutsideClick = [];
3650+
tick();
3651+
const callId = overlay.show(overlay.attach(SimpleDynamicComponent), overlaySettings);
3652+
tick();
3653+
3654+
expect(overlay.show).toHaveBeenCalledTimes(2);
3655+
divElement.click();
3656+
tick();
3657+
3658+
expect(overlay.onClosing.emit).toHaveBeenCalledTimes(2);
3659+
expect(overlay.onClosed.emit).toHaveBeenCalledTimes(2);
3660+
expect(overlay.onClosing.emit)
3661+
.toHaveBeenCalledWith({
3662+
id: callId, componentRef: jasmine.any(ComponentRef) as any, cancel: false,
3663+
event: new MouseEvent('click')
3664+
});
3665+
}));
36173666
});
36183667

36193668
describe('Integration tests p3 (IgniteUI components): ', () => {

0 commit comments

Comments
 (0)