@@ -123,6 +123,12 @@ describe('uib-accordion', function() {
123123 $templateCache = _$templateCache_ ;
124124 } ) ) ;
125125
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+
126132 it ( 'should expose the controller on the view' , function ( ) {
127133 $templateCache . put ( 'uib/template/accordion/accordion.html' , '<div>{{accordion.text}}</div>' ) ;
128134
@@ -150,6 +156,9 @@ describe('uib-accordion', function() {
150156 describe ( 'uib-accordion-group' , function ( ) {
151157 var scope , $compile ;
152158 var element , groups ;
159+ var findGroupHeading = function ( index ) {
160+ return groups . eq ( index ) . find ( '.panel-heading' ) . eq ( 0 ) ;
161+ } ;
153162 var findGroupLink = function ( index ) {
154163 return groups . eq ( index ) . find ( '.accordion-toggle' ) . eq ( 0 ) ;
155164 } ;
@@ -177,6 +186,7 @@ describe('uib-accordion', function() {
177186
178187 describe ( 'with static panels' , function ( ) {
179188 beforeEach ( function ( ) {
189+ spyOn ( Math , 'random' ) . and . returnValue ( 0.1 ) ;
180190 var tpl =
181191 '<uib-accordion>' +
182192 '<uib-accordion-group heading="title 1">Content 1</uib-accordion-group>' +
@@ -204,20 +214,26 @@ describe('uib-accordion', function() {
204214 findGroupLink ( 0 ) . click ( ) ;
205215 scope . $digest ( ) ;
206216 expect ( findGroupBody ( 0 ) . scope ( ) . isOpen ) . toBe ( true ) ;
217+ expect ( findGroupHeading ( 0 ) . html ( ) ) . toContain ( 'aria-expanded="true"' ) ;
207218
208219 findGroupLink ( 1 ) . click ( ) ;
209220 scope . $digest ( ) ;
210221 expect ( findGroupBody ( 0 ) . scope ( ) . isOpen ) . toBe ( false ) ;
222+ expect ( findGroupHeading ( 0 ) . html ( ) ) . toContain ( 'aria-expanded="false"' ) ;
211223 expect ( findGroupBody ( 1 ) . scope ( ) . isOpen ) . toBe ( true ) ;
224+ expect ( findGroupHeading ( 1 ) . html ( ) ) . toContain ( 'aria-expanded="true"' ) ;
212225 } ) ;
213226
214227 it ( 'should toggle element on click' , function ( ) {
215228 findGroupLink ( 0 ) . click ( ) ;
216229 scope . $digest ( ) ;
217230 expect ( findGroupBody ( 0 ) . scope ( ) . isOpen ) . toBe ( true ) ;
231+ expect ( groups . eq ( 0 ) . html ( ) ) . toContain ( 'aria-hidden="false"' ) ;
232+
218233 findGroupLink ( 0 ) . click ( ) ;
219234 scope . $digest ( ) ;
220235 expect ( findGroupBody ( 0 ) . scope ( ) . isOpen ) . toBe ( false ) ;
236+ expect ( groups . eq ( 0 ) . html ( ) ) . toContain ( 'aria-hidden="true"' ) ;
221237 } ) ;
222238
223239 it ( 'should add, by default, "panel-open" when opened' , function ( ) {
@@ -256,6 +272,16 @@ describe('uib-accordion', function() {
256272
257273 expect ( group ) . not . toHaveClass ( 'panel-open' ) ;
258274 } ) ;
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+ } ) ;
259285 } ) ;
260286
261287 describe ( 'with open-class attribute' , function ( ) {
0 commit comments