File tree 2 files changed +7
-7
lines changed
2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -186,16 +186,18 @@ describe('MatSnackBar', () => {
186
186
} ) ) ;
187
187
188
188
189
- it ( 'should clear the announcement message if it is the same as main message' , fakeAsync ( ( ) => {
189
+ it ( 'should default to the passed message for the announcement message' , fakeAsync ( ( ) => {
190
190
spyOn ( liveAnnouncer , 'announce' ) ;
191
191
192
- snackBar . open ( simpleMessage , undefined , { announcementMessage : simpleMessage } ) ;
192
+ snackBar . open ( simpleMessage ) ;
193
193
viewContainerFixture . detectChanges ( ) ;
194
194
195
195
expect ( overlayContainerElement . childElementCount )
196
196
. toBe ( 1 , 'Expected the overlay with the default announcement message to be added' ) ;
197
197
198
- expect ( liveAnnouncer . announce ) . not . toHaveBeenCalled ( ) ;
198
+ // Expect the live announcer to have been called with the display message and some
199
+ // string for the politeness. We do not want to test for the default politeness here.
200
+ expect ( liveAnnouncer . announce ) . toHaveBeenCalledWith ( simpleMessage , jasmine . any ( String ) ) ;
199
201
} ) ) ;
200
202
201
203
it ( 'should be able to specify a custom announcement message' , fakeAsync ( ( ) => {
Original file line number Diff line number Diff line change @@ -114,10 +114,8 @@ export class MatSnackBar implements OnDestroy {
114
114
// override the data to pass in our own message and action.
115
115
_config . data = { message, action} ;
116
116
117
- // Since the snack bar has `role="alert"`, we don't
118
- // want to announce the same message twice.
119
- if ( _config . announcementMessage === message ) {
120
- _config . announcementMessage = undefined ;
117
+ if ( ! _config . announcementMessage ) {
118
+ _config . announcementMessage = message ;
121
119
}
122
120
123
121
return this . openFromComponent ( SimpleSnackBar , _config ) ;
You can’t perform that action at this time.
0 commit comments