Skip to content

Commit 57b54bc

Browse files
authored
Merge pull request #9949 from IgniteUI/mvenkov/fix-overlay-failing-tests
Fix failing tests
2 parents e7f95cd + a0169fd commit 57b54bc

File tree

1 file changed

+26
-16
lines changed

1 file changed

+26
-16
lines changed

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

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3948,7 +3948,6 @@ describe('igxOverlay', () => {
39483948
}));
39493949

39503950
it('Should collapse/close the component when click outside it (DropDown, DatePicker, NavBar etc.)', fakeAsync(async () => {
3951-
// TO DO replace Spies with css class and/or getBoundingClientRect.
39523951
TestBed.overrideComponent(EmptyPageComponent, {
39533952
set: {
39543953
styles: [
@@ -3976,15 +3975,15 @@ describe('igxOverlay', () => {
39763975
expect(overlay.show).toHaveBeenCalledTimes(1);
39773976
expect(overlay.closing.emit).toHaveBeenCalledTimes(0);
39783977

3979-
fixture.componentInstance.buttonElement.nativeElement.click();
3978+
document.documentElement.click();
39803979
tick();
3981-
// TODO
3982-
// expect(overlay.closing.emit).toHaveBeenCalledTimes(1);
3983-
// .toHaveBeenCalledWith(
3984-
// {
3985-
// id: firstCallId, componentRef: jasmine.any(ComponentRef) as any, cancel: false,
3986-
// event: new MouseEvent('click')
3987-
// }
3980+
expect(overlay.closing.emit).toHaveBeenCalledTimes(1);
3981+
expect(overlay.closing.emit).toHaveBeenCalledWith({
3982+
id: firstCallId,
3983+
componentRef: jasmine.any(ComponentRef) as any,
3984+
cancel: false,
3985+
event: jasmine.any(Event) as any
3986+
});
39883987
}));
39893988

39903989
it('Should remain opened when click is on an element contained in the excludeFromOutsideClick collection', fakeAsync(async () => {
@@ -4004,7 +4003,8 @@ describe('igxOverlay', () => {
40044003
spyOn(overlay.closing, 'emit');
40054004
spyOn(overlay.closed, 'emit');
40064005

4007-
overlay.show(overlay.attach(SimpleDynamicComponent), overlaySettings);
4006+
let callId = overlay.attach(SimpleDynamicComponent, overlaySettings);
4007+
overlay.show(callId);
40084008
tick();
40094009
expect(overlay.show).toHaveBeenCalledTimes(1);
40104010

@@ -4018,10 +4018,18 @@ describe('igxOverlay', () => {
40184018
tick();
40194019
expect(overlay.closing.emit).toHaveBeenCalledTimes(1);
40204020
expect(overlay.closed.emit).toHaveBeenCalledTimes(1);
4021+
expect(overlay.closing.emit)
4022+
.toHaveBeenCalledWith({
4023+
id: callId,
4024+
componentRef: jasmine.any(ComponentRef) as any,
4025+
cancel: false,
4026+
event: undefined
4027+
});
4028+
overlay.detachAll();
40214029

40224030
overlaySettings.excludeFromOutsideClick = [];
40234031
tick();
4024-
const callId = overlay.attach(SimpleDynamicComponent, overlaySettings);
4032+
callId = overlay.attach(SimpleDynamicComponent, overlaySettings);
40254033
overlay.show(callId);
40264034
tick();
40274035

@@ -4031,11 +4039,13 @@ describe('igxOverlay', () => {
40314039

40324040
expect(overlay.closing.emit).toHaveBeenCalledTimes(2);
40334041
expect(overlay.closed.emit).toHaveBeenCalledTimes(2);
4034-
// expect(overlay.closing.emit)
4035-
// .toHaveBeenCalledWith({
4036-
// id: callId, componentRef: jasmine.any(ComponentRef) as any, cancel: false,
4037-
// event: new MouseEvent('click')
4038-
// });
4042+
expect(overlay.closing.emit)
4043+
.toHaveBeenCalledWith({
4044+
id: callId,
4045+
componentRef: jasmine.any(ComponentRef) as any,
4046+
cancel: false,
4047+
event: jasmine.any(Event) as any
4048+
});
40394049
}));
40404050
});
40414051

0 commit comments

Comments
 (0)