diff --git a/src/Collapse.js b/src/Collapse.js index 2a632f55e9..ab8e4b652f 100644 --- a/src/Collapse.js +++ b/src/Collapse.js @@ -48,7 +48,7 @@ class Collapse extends React.Component { + ref='panel'> {this.renderBody()} diff --git a/test/CollapseSpec.js b/test/CollapseSpec.js index 0ac893fcf0..8b7f71509c 100644 --- a/test/CollapseSpec.js +++ b/test/CollapseSpec.js @@ -213,4 +213,24 @@ describe('Collapse', function () { assert.equal(instance.collapse._dimension(), 'whatevs'); }); }); + + describe('with a role', function() { + beforeEach(function(){ + instance = ReactTestUtils.renderIntoDocument( + Panel content + ); + }); + + it('sets aria-expanded true when expanded', function() { + let node = React.findDOMNode(instance); + instance.setProps({ in: true}); + assert.equal(node.getAttribute('aria-expanded'), 'true'); + }); + + it('sets aria-expanded false when collapsed', function() { + let node = React.findDOMNode(instance); + instance.setProps({ in: false}); + assert.equal(node.getAttribute('aria-expanded'), 'false'); + }); + }); }); diff --git a/test/PanelSpec.js b/test/PanelSpec.js index aba23266d0..0c9cfc09f1 100644 --- a/test/PanelSpec.js +++ b/test/PanelSpec.js @@ -191,9 +191,7 @@ describe('Panel', function () { let instance = ReactTestUtils.renderIntoDocument( Panel content ); - let collapse = React.findDOMNode(instance).querySelector('.panel-collapse'); let anchor = React.findDOMNode(instance).querySelector('.panel-title a'); - assert.equal(collapse.getAttribute('aria-expanded'), 'true'); assert.equal(anchor.getAttribute('aria-expanded'), 'true'); }); @@ -201,9 +199,7 @@ describe('Panel', function () { let instance = ReactTestUtils.renderIntoDocument( Panel content ); - let collapse = React.findDOMNode(instance).querySelector('.panel-collapse'); let anchor = React.findDOMNode(instance).querySelector('.panel-title a'); - assert.equal(collapse.getAttribute('aria-expanded'), 'false'); assert.equal(anchor.getAttribute('aria-expanded'), 'false'); });