|
9 | 9 | } from '@angular/core/testing'; |
10 | 10 | import {NgModule, Component, Directive, ViewChild, ViewContainerRef} from '@angular/core'; |
11 | 11 | import {MdSnackBar, MdSnackBarModule} from './snack-bar'; |
| 12 | +import {MdSnackBarConfig} from './snack-bar-config'; |
12 | 13 | import {OverlayContainer, MdLiveAnnouncer} from '../core'; |
13 | 14 | import {SimpleSnackBar} from './simple-snack-bar'; |
14 | 15 |
|
@@ -280,13 +281,30 @@ describe('MdSnackBar', () => { |
280 | 281 | viewContainerFixture.detectChanges(); |
281 | 282 | flushMicrotasks(); |
282 | 283 |
|
283 | | - viewContainerFixture.whenStable().then(() => { |
284 | | - expect(dismissObservableCompleted).toBeTruthy('Expected the snack bar to be dismissed'); |
285 | | - expect(actionObservableCompleted).toBeTruthy('Expected the snack bar to notify of action'); |
286 | | - }); |
| 284 | + expect(dismissObservableCompleted).toBeTruthy('Expected the snack bar to be dismissed'); |
| 285 | + expect(actionObservableCompleted).toBeTruthy('Expected the snack bar to notify of action'); |
287 | 286 |
|
288 | 287 | tick(500); |
289 | 288 | })); |
| 289 | + |
| 290 | + it('should dismiss automatically after a specified timeout', fakeAsync(() => { |
| 291 | + let dismissObservableCompleted = false; |
| 292 | + let config = new MdSnackBarConfig(); |
| 293 | + config.dismiss = 250; |
| 294 | + let snackBarRef = snackBar.open('content', 'test', config); |
| 295 | + snackBarRef.afterDismissed().subscribe(null, null, () => { |
| 296 | + dismissObservableCompleted = true; |
| 297 | + }); |
| 298 | + |
| 299 | + viewContainerFixture.detectChanges(); |
| 300 | + flushMicrotasks(); |
| 301 | + expect(dismissObservableCompleted).toBeFalsy('Expected the snack bar not to be dismissed'); |
| 302 | + |
| 303 | + tick(1000); |
| 304 | + viewContainerFixture.detectChanges(); |
| 305 | + flushMicrotasks(); |
| 306 | + expect(dismissObservableCompleted).toBeTruthy('Expected the snack bar to be dismissed'); |
| 307 | + })); |
290 | 308 | }); |
291 | 309 |
|
292 | 310 | @Directive({selector: 'dir-with-view-container'}) |
|
0 commit comments