@@ -67,17 +67,31 @@ describe('MatSnackBar', () => {
67
67
testViewContainerRef = viewContainerFixture . componentInstance . childViewContainer ;
68
68
} ) ;
69
69
70
- it ( 'should have the role of `alert` with an `assertive` politeness' , ( ) => {
71
- snackBar . open ( simpleMessage , simpleActionLabel , { politeness : 'assertive' } ) ;
70
+ it ( 'should have the role of `alert` with an `assertive` politeness if no announcement message ' +
71
+ 'is provided' , ( ) => {
72
+ snackBar . openFromComponent ( BurritosNotification ,
73
+ { announcementMessage : '' , politeness : 'assertive' } ) ;
74
+
72
75
viewContainerFixture . detectChanges ( ) ;
73
76
74
77
const containerElement = overlayContainerElement . querySelector ( 'snack-bar-container' ) ! ;
75
78
expect ( containerElement . getAttribute ( 'role' ) )
76
79
. toBe ( 'alert' , 'Expected snack bar container to have role="alert"' ) ;
77
80
} ) ;
78
81
82
+ it ( 'should have the role of `status` with an `assertive` politeness if an announcement message ' +
83
+ 'is provided' , ( ) => {
84
+ snackBar . openFromComponent ( BurritosNotification ,
85
+ { announcementMessage : 'Yay Burritos' , politeness : 'assertive' } ) ;
86
+ viewContainerFixture . detectChanges ( ) ;
87
+
88
+ const containerElement = overlayContainerElement . querySelector ( 'snack-bar-container' ) ! ;
89
+ expect ( containerElement . getAttribute ( 'role' ) )
90
+ . toBe ( 'status' , 'Expected snack bar container to have role="status"' ) ;
91
+ } ) ;
92
+
79
93
it ( 'should have the role of `status` with a `polite` politeness' , ( ) => {
80
- snackBar . open ( simpleMessage , simpleActionLabel , { politeness : 'polite' } ) ;
94
+ snackBar . openFromComponent ( BurritosNotification , { politeness : 'polite' } ) ;
81
95
viewContainerFixture . detectChanges ( ) ;
82
96
83
97
const containerElement = overlayContainerElement . querySelector ( 'snack-bar-container' ) ! ;
@@ -86,7 +100,7 @@ describe('MatSnackBar', () => {
86
100
} ) ;
87
101
88
102
it ( 'should remove the role if the politeness is turned off' , ( ) => {
89
- snackBar . open ( simpleMessage , simpleActionLabel , { politeness : 'off' } ) ;
103
+ snackBar . openFromComponent ( BurritosNotification , { politeness : 'off' } ) ;
90
104
viewContainerFixture . detectChanges ( ) ;
91
105
92
106
const containerElement = overlayContainerElement . querySelector ( 'snack-bar-container' ) ! ;
0 commit comments