|
1 |
| -import {TestBed, async, ComponentFixture} from '@angular/core/testing'; |
| 1 | +import {TestBed, async, ComponentFixture, fakeAsync, tick} from '@angular/core/testing'; |
2 | 2 | import {By} from '@angular/platform-browser';
|
3 | 3 | import {NoopAnimationsModule} from '@angular/platform-browser/animations';
|
4 | 4 | import {
|
@@ -83,29 +83,31 @@ describe('MdMenu', () => {
|
83 | 83 | }).not.toThrowError();
|
84 | 84 | });
|
85 | 85 |
|
86 |
| - it('should close the menu when a click occurs outside the menu', () => { |
| 86 | + it('should close the menu when a click occurs outside the menu', fakeAsync(() => { |
87 | 87 | const fixture = TestBed.createComponent(SimpleMenu);
|
88 | 88 | fixture.detectChanges();
|
89 | 89 | fixture.componentInstance.trigger.openMenu();
|
90 | 90 |
|
91 | 91 | const backdrop = <HTMLElement>overlayContainerElement.querySelector('.cdk-overlay-backdrop');
|
92 | 92 | backdrop.click();
|
93 | 93 | fixture.detectChanges();
|
| 94 | + tick(500); |
94 | 95 |
|
95 | 96 | expect(overlayContainerElement.textContent).toBe('');
|
96 |
| - }); |
| 97 | + })); |
97 | 98 |
|
98 |
| - it('should close the menu when pressing escape', () => { |
| 99 | + it('should close the menu when pressing escape', fakeAsync(() => { |
99 | 100 | const fixture = TestBed.createComponent(SimpleMenu);
|
100 | 101 | fixture.detectChanges();
|
101 | 102 | fixture.componentInstance.trigger.openMenu();
|
102 | 103 |
|
103 | 104 | const panel = overlayContainerElement.querySelector('.mat-menu-panel')!;
|
104 | 105 | dispatchKeyboardEvent(panel, 'keydown', ESCAPE);
|
105 | 106 | fixture.detectChanges();
|
| 107 | + tick(500); |
106 | 108 |
|
107 | 109 | expect(overlayContainerElement.textContent).toBe('');
|
108 |
| - }); |
| 110 | + })); |
109 | 111 |
|
110 | 112 | it('should open a custom menu', () => {
|
111 | 113 | const fixture = TestBed.createComponent(CustomMenu);
|
|
0 commit comments