From b34b440ee309aa7484bafcbed85866c2bd302e90 Mon Sep 17 00:00:00 2001 From: Kristiyan Kostadinov Date: Thu, 27 Jul 2017 19:52:00 +0300 Subject: [PATCH] test(menu): fix test failures against Angular 4.2 (#5168) Fixes a couple of menu unit tests that were failing against Angular 4.2.2. --- src/lib/menu/menu.spec.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/lib/menu/menu.spec.ts b/src/lib/menu/menu.spec.ts index f4a755dda82..3ea7b72c9af 100644 --- a/src/lib/menu/menu.spec.ts +++ b/src/lib/menu/menu.spec.ts @@ -1,4 +1,4 @@ -import {TestBed, async, ComponentFixture} from '@angular/core/testing'; +import {TestBed, async, ComponentFixture, fakeAsync, tick} from '@angular/core/testing'; import {By} from '@angular/platform-browser'; import {NoopAnimationsModule} from '@angular/platform-browser/animations'; import { @@ -83,7 +83,7 @@ describe('MdMenu', () => { }).not.toThrowError(); }); - it('should close the menu when a click occurs outside the menu', () => { + it('should close the menu when a click occurs outside the menu', fakeAsync(() => { const fixture = TestBed.createComponent(SimpleMenu); fixture.detectChanges(); fixture.componentInstance.trigger.openMenu(); @@ -91,11 +91,12 @@ describe('MdMenu', () => { const backdrop = overlayContainerElement.querySelector('.cdk-overlay-backdrop'); backdrop.click(); fixture.detectChanges(); + tick(500); expect(overlayContainerElement.textContent).toBe(''); - }); + })); - it('should close the menu when pressing escape', () => { + it('should close the menu when pressing escape', fakeAsync(() => { const fixture = TestBed.createComponent(SimpleMenu); fixture.detectChanges(); fixture.componentInstance.trigger.openMenu(); @@ -103,9 +104,10 @@ describe('MdMenu', () => { const panel = overlayContainerElement.querySelector('.mat-menu-panel')!; dispatchKeyboardEvent(panel, 'keydown', ESCAPE); fixture.detectChanges(); + tick(500); expect(overlayContainerElement.textContent).toBe(''); - }); + })); it('should open a custom menu', () => { const fixture = TestBed.createComponent(CustomMenu);