Skip to content

Commit 5929899

Browse files
committed
test(tooltip): add zoneless sticky tooltip test
1 parent 4becfc6 commit 5929899

1 file changed

Lines changed: 36 additions & 2 deletions

File tree

projects/igniteui-angular/directives/src/directives/tooltip/tooltip.directive.spec.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import { DebugElement } from '@angular/core';
1+
import { DebugElement, ErrorHandler, provideZonelessChangeDetection } from '@angular/core';
22
import { fakeAsync, TestBed, tick, flush, waitForAsync, ComponentFixture } from '@angular/core/testing';
33
import { By } from '@angular/platform-browser';
44
import { NoopAnimationsModule } from '@angular/platform-browser/animations';
55
import { IgxTooltipSingleTargetComponent, IgxTooltipMultipleTargetsComponent, IgxTooltipPlainStringComponent, IgxTooltipWithToggleActionComponent, IgxTooltipWithCloseButtonComponent, IgxTooltipWithNestedContentComponent, IgxTooltipNestedTooltipsComponent } from '../../../../test-utils/tooltip-components.spec';
6-
import { UIInteractions } from '../../../../test-utils/ui-interactions.spec';
6+
import { UIInteractions, wait } from '../../../../test-utils/ui-interactions.spec';
77
import { HorizontalAlignment, VerticalAlignment, AutoPositionStrategy } from '../../../../core/src/services/public_api';
88
import { IgxTooltipDirective } from './tooltip.directive';
99
import { IgxTooltipTargetDirective } from './tooltip-target.directive';
@@ -1101,6 +1101,40 @@ describe('IgxTooltip', () => {
11011101
expect(closeBtn).toBeTruthy();
11021102
expect(tooltipNativeElement.getAttribute('role')).toBe('status');
11031103
}));
1104+
1105+
describe('Zoneless', () => {
1106+
beforeEach(async () => {
1107+
TestBed.resetTestingModule();
1108+
await TestBed.configureTestingModule({
1109+
imports: [
1110+
NoopAnimationsModule,
1111+
IgxTooltipWithCloseButtonComponent
1112+
],
1113+
providers: [provideZonelessChangeDetection()]
1114+
}).compileComponents();
1115+
});
1116+
1117+
beforeEach(() => {
1118+
fix = TestBed.createComponent(IgxTooltipWithCloseButtonComponent);
1119+
fix.detectChanges();
1120+
tooltipNativeElement = fix.debugElement.query(By.directive(IgxTooltipDirective)).nativeElement;
1121+
tooltipTarget = fix.componentInstance.tooltipTarget as IgxTooltipTargetDirective;
1122+
button = fix.debugElement.query(By.directive(IgxTooltipTargetDirective));
1123+
});
1124+
1125+
it('should not throw ExpressionChangedAfterItHasBeenChecked when showing sticky tooltip with close button', async () => {
1126+
const errorHandler = TestBed.inject(ErrorHandler);
1127+
const handleErrorSpy = spyOn(errorHandler, 'handleError');
1128+
1129+
hoverElement(button);
1130+
await wait(SHOW_DELAY + 50);
1131+
fix.detectChanges();
1132+
1133+
expect(handleErrorSpy).not.toHaveBeenCalled();
1134+
verifyTooltipVisibility(tooltipNativeElement, tooltipTarget, true);
1135+
expect(tooltipNativeElement.getAttribute('role')).toBe('status');
1136+
});
1137+
});
11041138
});
11051139

11061140
describe('IgxTooltip placement and offset', () => {

0 commit comments

Comments
 (0)