Skip to content

Commit

Permalink
Add tests checking correct active state handling after removing tab pane
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKVal committed Jul 25, 2015
1 parent 485b33f commit 82c4488
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions test/TabbedAreaSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import TabbedArea from '../src/TabbedArea';
import NavItem from '../src/NavItem';
import TabPane from '../src/TabPane';
import ValidComponentChildren from '../src/utils/ValidComponentChildren';
import { render } from './helpers';

describe('TabbedArea', function () {
it('Should show the correct tab', function () {
Expand Down Expand Up @@ -230,6 +231,48 @@ describe('TabbedArea', function () {
assert.equal(tabbedArea.refs.tabs.props.activeKey, 2);
});

describe('animation', function () {
let mountPoint;

beforeEach(()=>{
mountPoint = document.createElement('div');
document.body.appendChild(mountPoint);
});

afterEach(function () {
React.unmountComponentAtNode(mountPoint);
document.body.removeChild(mountPoint);
});

function checkTabRemovingWithAnimation(animation) {
it(`should correctly set "active" after tabPane is removed with "animation=${animation}"`, function() {
let instance = render(
<TabbedArea activeKey={2} animation={animation}>
<TabPane tab="Tab 1" eventKey={1}>Tab 1 content</TabPane>
<TabPane tab="Tab 2" eventKey={2}>Tab 2 content</TabPane>
</TabbedArea>
, mountPoint);

let panes = ReactTestUtils.scryRenderedComponentsWithType(instance, TabPane);

assert.equal(panes[0].props.active, false);
assert.equal(panes[1].props.active, true);

// second tab has been removed
render(
<TabbedArea activeKey={1} animation={animation}>
<TabPane tab="Tab 1" eventKey={1}>Tab 1 content</TabPane>
</TabbedArea>
, mountPoint);

assert.equal(panes[0].props.active, true);
});
}

checkTabRemovingWithAnimation(true);
checkTabRemovingWithAnimation(false);
});

describe('Web Accessibility', function(){

it('Should generate ids from parent id', function () {
Expand Down

0 comments on commit 82c4488

Please sign in to comment.