Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/lib/snack-bar/snack-bar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,19 @@ describe('MdSnackBar', () => {
});
}));

it('should be able to get dismissed through the service', async(() => {
snackBar.open(simpleMessage);
viewContainerFixture.detectChanges();
expect(overlayContainerElement.childElementCount).toBeGreaterThan(0);

snackBar.dismiss();
viewContainerFixture.detectChanges();

viewContainerFixture.whenStable().then(() => {
expect(overlayContainerElement.childElementCount).toBe(0);
});
}));

it('should clean itself up when the view container gets destroyed', async(() => {
snackBar.open(simpleMessage, null, { viewContainerRef: testViewContainerRef });
viewContainerFixture.detectChanges();
Expand Down
9 changes: 9 additions & 0 deletions src/lib/snack-bar/snack-bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ export class MdSnackBar {
return simpleSnackBarRef;
}

/**
* Dismisses the currently-visible snack bar.
*/
dismiss(): void {
if (this._openedSnackBarRef) {
this._openedSnackBarRef.dismiss();
}
}

/**
* Attaches the snack bar container component to the overlay.
*/
Expand Down