Skip to content

Commit 8f3c2e9

Browse files
committed
fix(cdk-experimental/listbox): fix tests
1 parent 18125ca commit 8f3c2e9

File tree

1 file changed

+32
-26
lines changed

1 file changed

+32
-26
lines changed

src/cdk-experimental/listbox/listbox.spec.ts

Lines changed: 32 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -356,19 +356,21 @@ describe('CdkOption and CdkListbox', () => {
356356
expect(fixture.componentInstance.changedOption).toBeUndefined();
357357
});
358358

359-
it('should not handle type ahead on a disabled listbox', fakeAsync(async () => {
359+
it('should not handle type ahead on a disabled listbox', async () => {
360360
const {fixture, testComponent, listboxEl, options} = await setupComponent(ListboxWithOptions);
361-
testComponent.isListboxDisabled = true;
362-
fixture.detectChanges();
361+
await fakeAsync(() => {
362+
testComponent.isListboxDisabled = true;
363+
fixture.detectChanges();
363364

364-
dispatchKeyboardEvent(listboxEl, 'keydown', B);
365-
fixture.detectChanges();
366-
tick(200);
365+
dispatchKeyboardEvent(listboxEl, 'keydown', B);
366+
fixture.detectChanges();
367+
tick(200);
367368

368-
for (let option of options) {
369-
expect(option.isActive()).toBeFalse();
370-
}
371-
}));
369+
for (let option of options) {
370+
expect(option.isActive()).toBeFalse();
371+
}
372+
})();
373+
});
372374

373375
it('should skip disabled options when navigating with arrow keys', async () => {
374376
const {testComponent, fixture, listbox, listboxEl, options} = await setupComponent(
@@ -438,31 +440,35 @@ describe('CdkOption and CdkListbox', () => {
438440
expect(optionEls[0].classList).toContain('cdk-option-active');
439441
});
440442

441-
it('should change active item using type ahead', fakeAsync(async () => {
443+
it('should change active item using type ahead', async () => {
442444
const {fixture, listbox, listboxEl, options} = await setupComponent(ListboxWithOptions);
443-
listbox.focus();
444-
fixture.detectChanges();
445+
await fakeAsync(() => {
446+
listbox.focus();
447+
fixture.detectChanges();
445448

446-
dispatchKeyboardEvent(listboxEl, 'keydown', B);
447-
fixture.detectChanges();
448-
tick(200);
449+
dispatchKeyboardEvent(listboxEl, 'keydown', B);
450+
fixture.detectChanges();
451+
tick(200);
449452

450-
expect(options[2].isActive()).toBeTrue();
451-
}));
453+
expect(options[2].isActive()).toBeTrue();
454+
})();
455+
});
452456

453-
it('should allow custom type ahead label', fakeAsync(async () => {
457+
it('should allow custom type ahead label', async () => {
454458
const {fixture, listbox, listboxEl, options} = await setupComponent(
455459
ListboxWithCustomTypeahead,
456460
);
457-
listbox.focus();
458-
fixture.detectChanges();
461+
await fakeAsync(() => {
462+
listbox.focus();
463+
fixture.detectChanges();
459464

460-
dispatchKeyboardEvent(listboxEl, 'keydown', B);
461-
fixture.detectChanges();
462-
tick(200);
465+
dispatchKeyboardEvent(listboxEl, 'keydown', B);
466+
fixture.detectChanges();
467+
tick(200);
463468

464-
expect(options[2].isActive()).toBeTrue();
465-
}));
469+
expect(options[2].isActive()).toBeTrue();
470+
});
471+
});
466472

467473
it('should focus and toggle the next item when pressing SHIFT + DOWN_ARROW', async () => {
468474
const {fixture, listbox, listboxEl, options} = await setupComponent(ListboxWithOptions);

0 commit comments

Comments
 (0)