|
1 |
| -import { |
2 |
| - inject, |
3 |
| - async, |
4 |
| - ComponentFixture, |
5 |
| - TestBed, |
6 |
| -} from '@angular/core/testing'; |
7 |
| -import { |
8 |
| - NgModule, |
9 |
| - Component, |
10 |
| - Directive, |
11 |
| - ViewChild, |
12 |
| - ViewContainerRef |
13 |
| -} from '@angular/core'; |
| 1 | +import {inject, async, ComponentFixture, TestBed} from '@angular/core/testing'; |
| 2 | +import {NgModule, Component, Directive, ViewChild, ViewContainerRef} from '@angular/core'; |
14 | 3 | import {MdSnackBar, MdSnackBarModule} from './snack-bar';
|
15 | 4 | import {OverlayContainer, MdLiveAnnouncer} from '../core';
|
16 | 5 | import {MdSnackBarConfig} from './snack-bar-config';
|
@@ -194,6 +183,26 @@ describe('MdSnackBar', () => {
|
194 | 183 | .toBe('visible', `Expected the animation state would be 'visible'.`);
|
195 | 184 | });
|
196 | 185 | }));
|
| 186 | + |
| 187 | + it('should open a new snackbar after dismissing a previous snackbar', async(() => { |
| 188 | + let config = new MdSnackBarConfig(testViewContainerRef); |
| 189 | + let snackBarRef = snackBar.open(simpleMessage, 'DISMISS', config); |
| 190 | + viewContainerFixture.detectChanges(); |
| 191 | + |
| 192 | + snackBarRef.dismiss(); |
| 193 | + viewContainerFixture.detectChanges(); |
| 194 | + |
| 195 | + // Wait for the snackbar dismiss animation to finish. |
| 196 | + viewContainerFixture.whenStable().then(() => { |
| 197 | + snackBarRef = snackBar.open('Second snackbar', 'DISMISS', config); |
| 198 | + viewContainerFixture.detectChanges(); |
| 199 | + |
| 200 | + // Wait for the snackbar open animation to finish. |
| 201 | + viewContainerFixture.whenStable().then(() => { |
| 202 | + expect(snackBarRef.containerInstance.animationState).toBe('visible'); |
| 203 | + }); |
| 204 | + }); |
| 205 | + })); |
197 | 206 | });
|
198 | 207 |
|
199 | 208 | @Directive({selector: 'dir-with-view-container'})
|
|
0 commit comments