From 82c4488890e4e6a167aeece47c9800fa493ed359 Mon Sep 17 00:00:00 2001 From: AlexKVal Date: Sat, 18 Jul 2015 19:02:28 +0300 Subject: [PATCH] Add tests checking correct active state handling after removing tab pane --- test/TabbedAreaSpec.js | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/TabbedAreaSpec.js b/test/TabbedAreaSpec.js index 5d8cf7c065..876b09dcb8 100644 --- a/test/TabbedAreaSpec.js +++ b/test/TabbedAreaSpec.js @@ -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 () { @@ -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( + + Tab 1 content + Tab 2 content + + , 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( + + Tab 1 content + + , mountPoint); + + assert.equal(panes[0].props.active, true); + }); + } + + checkTabRemovingWithAnimation(true); + checkTabRemovingWithAnimation(false); + }); + describe('Web Accessibility', function(){ it('Should generate ids from parent id', function () {