Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions projects/igniteui-angular/src/lib/combo/combo.component.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1745,71 +1745,60 @@
expect(dropdown).toBeDefined();
expect(dropdown.focusedItem).toBeFalsy();
expect(combo.virtualScrollContainer).toBeDefined();
combo.allowCustomValues = true;
const mockClick = jasmine.createSpyObj('event', ['preventDefault', 'stopPropagation']);
const virtualMockUP = spyOn<any>(dropdown, 'navigatePrev').and.callThrough();
const virtualMockDOWN = spyOn<any>(dropdown, 'navigateNext').and.callThrough();
expect(dropdown.focusedItem).toEqual(null);
expect(combo.collapsed).toBeTruthy();
combo.toggle();
await wait(30);
await wait();
fixture.detectChanges();
expect(combo.collapsed).toBeFalsy();
combo.virtualScrollContainer.scrollTo(51);
await wait(30);
await firstValueFrom(combo.virtualScrollContainer.chunkLoad);
fixture.detectChanges();
let items = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_DROPDOWNLISTITEM}`));

Check warning on line 1761 in projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

View workflow job for this annotation

GitHub Actions / run-tests (18.x)

'items' is never reassigned. Use 'const' instead

Check warning on line 1761 in projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

View workflow job for this annotation

GitHub Actions / run-tests (20.x)

'items' is never reassigned. Use 'const' instead
let lastItem = items[items.length - 1].componentInstance;

Check warning on line 1762 in projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

View workflow job for this annotation

GitHub Actions / run-tests (18.x)

'lastItem' is never reassigned. Use 'const' instead

Check warning on line 1762 in projects/igniteui-angular/src/lib/combo/combo.component.spec.ts

View workflow job for this annotation

GitHub Actions / run-tests (20.x)

'lastItem' is never reassigned. Use 'const' instead
expect(lastItem).toBeDefined();
lastItem.clicked(mockClick);
await wait(30);
fixture.detectChanges();
expect(dropdown.focusedItem).toEqual(lastItem);
dropdown.navigateItem(-1);
await wait(30);
fixture.detectChanges();
expect(virtualMockDOWN).toHaveBeenCalledTimes(0);
lastItem.clicked(mockClick);
await wait(30);
fixture.detectChanges();
expect(dropdown.focusedItem).toEqual(lastItem);
dropdown.navigateNext();
await wait(30);
fixture.detectChanges();
expect(virtualMockDOWN).toHaveBeenCalledTimes(1);
combo.searchValue = 'New';
combo.handleInputChange();
fixture.detectChanges();
await wait(30);
items = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_DROPDOWNLISTITEM}`));
lastItem = items[items.length - 1].componentInstance;
(lastItem as IgxComboAddItemComponent).clicked(mockClick);
await wait(30);
await firstValueFrom(combo.virtualScrollContainer.chunkLoad);
const addItemButton = fixture.debugElement.query(By.directive(IgxComboAddItemComponent));
addItemButton.triggerEventHandler('click', UIInteractions.getMouseEvent('click'));
fixture.detectChanges();
// After `Add Item` is clicked, the input is focused and the item is added to the list
// expect(dropdown.focusedItem).toEqual(null);
expect(dropdown.focusedItem).toEqual(null);
expect(document.activeElement).toEqual(combo.searchInput.nativeElement);
expect(combo.customValueFlag).toBeFalsy();
expect(combo.searchInput.nativeElement.value).toBeTruthy();

// TEST move from first item
combo.virtualScrollContainer.scrollTo(0);
await wait();
fixture.detectChanges();
const firstItem = fixture.debugElement.queryAll(By.css(`.${CSS_CLASS_DROPDOWNLISTITEM}`))[0].componentInstance;
firstItem.clicked(mockClick);
await wait(30);
fixture.detectChanges();
expect(dropdown.focusedItem).toEqual(firstItem);
expect(dropdown.focusedItem.itemIndex).toEqual(0);
// spyOnProperty(dropdown, 'focusedItem', 'get').and.returnValue(firstItem);
dropdown.navigateFirst();
await wait(30);
fixture.detectChanges();
dropdown.navigatePrev();
await wait(30);
fixture.detectChanges();
// Called once before the `await` and called once more, because item @ index 0 is a header
// Called once manually and called once more, because item @ index 0 is a header
expect(virtualMockUP).toHaveBeenCalledTimes(2);
expect(dropdown.focusedItem).toBeNull();
}));
it('should properly get the first focusable item when focusing the component list', () => {
const expectedItemText = 'State: MichiganRegion: East North Central';
Expand Down
Loading