Skip to content

Commit 62a86cc

Browse files
committed
chore: add test
1 parent bee5f83 commit 62a86cc

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

src/lib/autocomplete/autocomplete-trigger.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ export class MdAutocompleteTrigger implements ControlValueAccessor, OnDestroy {
198198

199199
/** Closes the autocomplete suggestion panel. */
200200
closePanel(): void {
201-
202201
if (this._overlayRef && this._overlayRef.hasAttached()) {
203202
this._overlayRef.detach();
204203
this._closingActionsSubscription.unsubscribe();

src/lib/autocomplete/autocomplete.spec.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,37 @@ describe('MdAutocomplete', () => {
344344
});
345345
}));
346346

347+
it('should toggle the visibility when typing and closing the panel', fakeAsync(() => {
348+
fixture.componentInstance.trigger.openPanel();
349+
tick();
350+
fixture.detectChanges();
351+
352+
expect(overlayContainerElement.querySelector('.mat-autocomplete-panel')!.classList)
353+
.toContain('mat-autocomplete-visible', 'Expected panel to be visible.');
354+
355+
typeInElement('x', input);
356+
fixture.detectChanges();
357+
tick();
358+
fixture.detectChanges();
359+
360+
expect(overlayContainerElement.querySelector('.mat-autocomplete-panel')!.classList)
361+
.toContain('mat-autocomplete-hidden', 'Expected panel to be hidden.');
362+
363+
fixture.componentInstance.trigger.closePanel();
364+
fixture.detectChanges();
365+
366+
fixture.componentInstance.trigger.openPanel();
367+
fixture.detectChanges();
368+
369+
typeInElement('al', input);
370+
fixture.detectChanges();
371+
tick();
372+
fixture.detectChanges();
373+
374+
expect(overlayContainerElement.querySelector('.mat-autocomplete-panel')!.classList)
375+
.toContain('mat-autocomplete-visible', 'Expected panel to be visible.');
376+
}));
377+
347378
});
348379

349380
it('should have the correct text direction in RTL', () => {

0 commit comments

Comments
 (0)