@@ -123,6 +123,12 @@ describe('uib-accordion', function() {
123
123
$templateCache = _$templateCache_ ;
124
124
} ) ) ;
125
125
126
+ it ( 'should be a tablist' , function ( ) {
127
+ element = $compile ( '<uib-accordion></uib-accordion>' ) ( scope ) ;
128
+ scope . $digest ( ) ;
129
+ expect ( element . html ( ) ) . toContain ( 'role="tablist"' ) ;
130
+ } ) ;
131
+
126
132
it ( 'should expose the controller on the view' , function ( ) {
127
133
$templateCache . put ( 'uib/template/accordion/accordion.html' , '<div>{{accordion.text}}</div>' ) ;
128
134
@@ -150,6 +156,9 @@ describe('uib-accordion', function() {
150
156
describe ( 'uib-accordion-group' , function ( ) {
151
157
var scope , $compile ;
152
158
var element , groups ;
159
+ var findGroupHeading = function ( index ) {
160
+ return groups . eq ( index ) . find ( '.panel-heading' ) . eq ( 0 ) ;
161
+ } ;
153
162
var findGroupLink = function ( index ) {
154
163
return groups . eq ( index ) . find ( '.accordion-toggle' ) . eq ( 0 ) ;
155
164
} ;
@@ -177,6 +186,7 @@ describe('uib-accordion', function() {
177
186
178
187
describe ( 'with static panels' , function ( ) {
179
188
beforeEach ( function ( ) {
189
+ spyOn ( Math , 'random' ) . and . returnValue ( 0.1 ) ;
180
190
var tpl =
181
191
'<uib-accordion>' +
182
192
'<uib-accordion-group heading="title 1">Content 1</uib-accordion-group>' +
@@ -204,20 +214,26 @@ describe('uib-accordion', function() {
204
214
findGroupLink ( 0 ) . click ( ) ;
205
215
scope . $digest ( ) ;
206
216
expect ( findGroupBody ( 0 ) . scope ( ) . isOpen ) . toBe ( true ) ;
217
+ expect ( findGroupHeading ( 0 ) . html ( ) ) . toContain ( 'aria-expanded="true"' ) ;
207
218
208
219
findGroupLink ( 1 ) . click ( ) ;
209
220
scope . $digest ( ) ;
210
221
expect ( findGroupBody ( 0 ) . scope ( ) . isOpen ) . toBe ( false ) ;
222
+ expect ( findGroupHeading ( 0 ) . html ( ) ) . toContain ( 'aria-expanded="false"' ) ;
211
223
expect ( findGroupBody ( 1 ) . scope ( ) . isOpen ) . toBe ( true ) ;
224
+ expect ( findGroupHeading ( 1 ) . html ( ) ) . toContain ( 'aria-expanded="true"' ) ;
212
225
} ) ;
213
226
214
227
it ( 'should toggle element on click' , function ( ) {
215
228
findGroupLink ( 0 ) . click ( ) ;
216
229
scope . $digest ( ) ;
217
230
expect ( findGroupBody ( 0 ) . scope ( ) . isOpen ) . toBe ( true ) ;
231
+ expect ( groups . eq ( 0 ) . html ( ) ) . toContain ( 'aria-hidden="false"' ) ;
232
+
218
233
findGroupLink ( 0 ) . click ( ) ;
219
234
scope . $digest ( ) ;
220
235
expect ( findGroupBody ( 0 ) . scope ( ) . isOpen ) . toBe ( false ) ;
236
+ expect ( groups . eq ( 0 ) . html ( ) ) . toContain ( 'aria-hidden="true"' ) ;
221
237
} ) ;
222
238
223
239
it ( 'should add, by default, "panel-open" when opened' , function ( ) {
@@ -256,6 +272,16 @@ describe('uib-accordion', function() {
256
272
257
273
expect ( group ) . not . toHaveClass ( 'panel-open' ) ;
258
274
} ) ;
275
+
276
+ it ( 'should generate an Id for the heading' , function ( ) {
277
+ var groupScope = findGroupBody ( 0 ) . scope ( ) ;
278
+ expect ( groupScope . headingId ) . toEqual ( 'accordiongroup-' + groupScope . $id + '-1000-tab' ) ;
279
+ } ) ;
280
+
281
+ it ( 'should generate an Id for the panel' , function ( ) {
282
+ var groupScope = findGroupBody ( 0 ) . scope ( ) ;
283
+ expect ( groupScope . panelId ) . toEqual ( 'accordiongroup-' + groupScope . $id + '-1000-panel' ) ;
284
+ } ) ;
259
285
} ) ;
260
286
261
287
describe ( 'with open-class attribute' , function ( ) {
0 commit comments