@@ -51,7 +51,7 @@ describe('progressbar directive', function() {
51
51
$compile = _$compile_ ;
52
52
$rootScope = _$rootScope_ ;
53
53
$rootScope . value = 22 ;
54
- element = $compile ( '<progressbar animate="false" value="value">{{value}} %</progressbar>' ) ( $rootScope ) ;
54
+ element = $compile ( '<progressbar animate="false" value="value" title="foo" >{{value}} %</progressbar>' ) ( $rootScope ) ;
55
55
$rootScope . $digest ( ) ;
56
56
} ) ) ;
57
57
@@ -81,6 +81,14 @@ describe('progressbar directive', function() {
81
81
expect ( bar . attr ( 'aria-valuemax' ) ) . toBe ( '100' ) ;
82
82
expect ( bar . attr ( 'aria-valuenow' ) ) . toBe ( '22' ) ;
83
83
expect ( bar . attr ( 'aria-valuetext' ) ) . toBe ( '22%' ) ;
84
+ expect ( bar . attr ( 'aria-labelledby' ) ) . toBe ( 'foo' ) ;
85
+ } ) ;
86
+
87
+ it ( 'has the default aria-labelledby value of `progressbar`' , function ( ) {
88
+ element = $compile ( '<progressbar animate="false" value="value">{{value}} %</progressbar>' ) ( $rootScope ) ;
89
+ $rootScope . $digest ( ) ;
90
+ var bar = getBar ( 0 ) ;
91
+ expect ( bar . attr ( 'aria-labelledby' ) ) . toBe ( 'progressbar' ) ;
84
92
} ) ;
85
93
86
94
it ( 'transcludes "bar" text' , function ( ) {
@@ -197,11 +205,11 @@ describe('progressbar directive', function() {
197
205
describe ( 'stacked' , function ( ) {
198
206
beforeEach ( inject ( function ( ) {
199
207
$rootScope . objects = [
200
- { value : 10 , type : 'success' } ,
201
- { value : 50 , type : 'warning' } ,
202
- { value : 20 }
208
+ { value : 10 , title : 'foo' , type : 'success' } ,
209
+ { value : 50 , title : 'bar' , type : 'warning' } ,
210
+ { value : 20 , title : 'baz' }
203
211
] ;
204
- element = $compile ( '<uib-progress animate="false"><uib-bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</uib-bar></uib-progress>' ) ( $rootScope ) ;
212
+ element = $compile ( '<uib-progress animate="false"><uib-bar ng-repeat="o in objects" value="o.value" type="{{o.type}}" title="{{o.title}}" >{{o.value}}</uib-bar></uib-progress>' ) ( $rootScope ) ;
205
213
$rootScope . $digest ( ) ;
206
214
} ) ) ;
207
215
@@ -261,6 +269,40 @@ describe('progressbar directive', function() {
261
269
expect ( getBar ( 0 ) ) . not . toHaveClass ( BAR_CLASS + '-warning' ) ;
262
270
} ) ;
263
271
272
+ it ( 'should have the correct aria markup' , function ( ) {
273
+ expect ( getBar ( 0 ) . attr ( 'aria-valuenow' ) ) . toBe ( '10' ) ;
274
+ expect ( getBar ( 0 ) . attr ( 'aria-valuemin' ) ) . toBe ( '0' ) ;
275
+ expect ( getBar ( 0 ) . attr ( 'aria-valuemax' ) ) . toBe ( '100' ) ;
276
+ expect ( getBar ( 0 ) . attr ( 'aria-valuetext' ) ) . toBe ( '10%' ) ;
277
+ expect ( getBar ( 0 ) . attr ( 'aria-labelledby' ) ) . toBe ( 'foo' ) ;
278
+
279
+ expect ( getBar ( 1 ) . attr ( 'aria-valuenow' ) ) . toBe ( '50' ) ;
280
+ expect ( getBar ( 1 ) . attr ( 'aria-valuemin' ) ) . toBe ( '0' ) ;
281
+ expect ( getBar ( 1 ) . attr ( 'aria-valuemax' ) ) . toBe ( '100' ) ;
282
+ expect ( getBar ( 1 ) . attr ( 'aria-valuetext' ) ) . toBe ( '50%' ) ;
283
+ expect ( getBar ( 1 ) . attr ( 'aria-labelledby' ) ) . toBe ( 'bar' ) ;
284
+
285
+ expect ( getBar ( 2 ) . attr ( 'aria-valuenow' ) ) . toBe ( '20' ) ;
286
+ expect ( getBar ( 2 ) . attr ( 'aria-valuemin' ) ) . toBe ( '0' ) ;
287
+ expect ( getBar ( 2 ) . attr ( 'aria-valuemax' ) ) . toBe ( '100' ) ;
288
+ expect ( getBar ( 2 ) . attr ( 'aria-valuetext' ) ) . toBe ( '20%' ) ;
289
+ expect ( getBar ( 2 ) . attr ( 'aria-labelledby' ) ) . toBe ( 'baz' ) ;
290
+ } ) ;
291
+
292
+ it ( 'should default to `progressbar`' , function ( ) {
293
+ $rootScope . objects = [
294
+ { value : 10 , title : 'foo' , type : 'success' } ,
295
+ { value : 50 , title : 'bar' , type : 'warning' } ,
296
+ { value : 20 , title : 'baz' }
297
+ ] ;
298
+ element = $compile ( '<uib-progress animate="false"><uib-bar ng-repeat="o in objects" value="o.value" type="{{o.type}}">{{o.value}}</uib-bar></uib-progress>' ) ( $rootScope ) ;
299
+ $rootScope . $digest ( ) ;
300
+
301
+ expect ( getBar ( 0 ) . attr ( 'aria-labelledby' ) ) . toBe ( 'progressbar' ) ;
302
+ expect ( getBar ( 1 ) . attr ( 'aria-labelledby' ) ) . toBe ( 'progressbar' ) ;
303
+ expect ( getBar ( 2 ) . attr ( 'aria-labelledby' ) ) . toBe ( 'progressbar' ) ;
304
+ } ) ;
305
+
264
306
describe ( '"max" attribute' , function ( ) {
265
307
beforeEach ( inject ( function ( ) {
266
308
$rootScope . max = 200 ;
0 commit comments