Skip to content

Commit cfde1fa

Browse files
committed
test(combo): zoneless + scroll ng0100 error
1 parent 0856ca9 commit cfde1fa

1 file changed

Lines changed: 61 additions & 2 deletions

File tree

projects/igniteui-angular/combo/src/combo/combo.component.spec.ts

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { AsyncPipe } from '@angular/common';
2-
import { AfterViewInit, ChangeDetectorRef, Component, DebugElement, ElementRef, Injectable, Injector, OnDestroy, OnInit, ViewChild, inject } from '@angular/core';
2+
import { AfterViewInit, ChangeDetectorRef, Component, DebugElement, ElementRef, Injectable, Injector, OnDestroy, OnInit, ViewChild, inject, provideZonelessChangeDetection } from '@angular/core';
33
import { ComponentFixture, fakeAsync, TestBed, tick, waitForAsync } from '@angular/core/testing';
44
import {
55
FormsModule, NgForm, NgModel, ReactiveFormsModule, UntypedFormBuilder, UntypedFormControl, UntypedFormGroup, Validators
@@ -2712,7 +2712,7 @@ describe('igxCombo', () => {
27122712
fixture.detectChanges();
27132713
expect(combo.dropdown.headers[0].element.nativeElement.innerText).toEqual('New England')
27142714
});
2715-
it('should sort groups with diacritics correctly', async() => {
2715+
it('should sort groups with diacritics correctly', async () => {
27162716
combo.data = [
27172717
{ field: "Alaska", region: "Méxícó" },
27182718
{ field: "California", region: "Méxícó" },
@@ -3706,6 +3706,65 @@ describe('igxCombo', () => {
37063706
}));
37073707
});
37083708
});
3709+
3710+
describe('Zoneless', () => {
3711+
beforeEach(async () => {
3712+
await TestBed.configureTestingModule({
3713+
imports: [
3714+
NoopAnimationsModule,
3715+
IgxComboComponent,
3716+
],
3717+
providers: [
3718+
provideZonelessChangeDetection()
3719+
]
3720+
}).compileComponents();
3721+
3722+
fixture = TestBed.createComponent(IgxComboSampleComponent);
3723+
fixture.detectChanges();
3724+
combo = fixture.componentInstance.combo;
3725+
});
3726+
3727+
it('should not reproduce NG0100 when virtualized combo items update on scroll - issue #17310', async () => {
3728+
combo.open();
3729+
await fixture.whenStable();
3730+
3731+
const scrollEl = combo.virtualScrollContainer.getScroll();
3732+
expect(scrollEl).toBeTruthy();
3733+
3734+
expect(() => {
3735+
scrollEl.scrollTop = 300;
3736+
scrollEl.dispatchEvent(new Event('scroll'));
3737+
3738+
fixture.whenStable();
3739+
fixture.detectChanges();
3740+
}).not.toThrowError(/NG0100|ExpressionChangedAfterItHasBeenCheckedError/);
3741+
});
3742+
3743+
it('should not reproduce NG0100 related to active descendant on scroll - issue #17310', fakeAsync(() => {
3744+
combo.toggle();
3745+
tick();
3746+
fixture.detectChanges();
3747+
3748+
const dropdownContent = fixture.debugElement.query(By.css(`.${CSS_CLASS_CONTENT}`));
3749+
dropdownContent.triggerEventHandler('focus', {});
3750+
tick();
3751+
fixture.detectChanges();
3752+
3753+
const activeDescendantId = combo.dropdown.activeDescendant;
3754+
expect(activeDescendantId).toBeTruthy();
3755+
3756+
fixture.detectChanges();
3757+
3758+
expect(() => {
3759+
const scrollEl = combo.virtualScrollContainer.getScroll();
3760+
scrollEl.scrollTop = 1000;
3761+
scrollEl.dispatchEvent(new Event('scroll'));
3762+
3763+
tick(100);
3764+
fixture.detectChanges();
3765+
}).not.toThrowError(/NG0100|ExpressionChangedAfterItHasBeenCheckedError/);
3766+
}));
3767+
});
37093768
});
37103769
});
37113770

0 commit comments

Comments
 (0)