@@ -4,6 +4,7 @@ import TabbedArea from '../src/TabbedArea';
44import NavItem from '../src/NavItem' ;
55import TabPane from '../src/TabPane' ;
66import ValidComponentChildren from '../src/utils/ValidComponentChildren' ;
7+ import { render } from './helpers' ;
78
89describe ( 'TabbedArea' , function ( ) {
910 it ( 'Should show the correct tab' , function ( ) {
@@ -230,6 +231,48 @@ describe('TabbedArea', function () {
230231 assert . equal ( tabbedArea . refs . tabs . props . activeKey , 2 ) ;
231232 } ) ;
232233
234+ describe ( 'animation' , function ( ) {
235+ let mountPoint ;
236+
237+ beforeEach ( ( ) => {
238+ mountPoint = document . createElement ( 'div' ) ;
239+ document . body . appendChild ( mountPoint ) ;
240+ } ) ;
241+
242+ afterEach ( function ( ) {
243+ React . unmountComponentAtNode ( mountPoint ) ;
244+ document . body . removeChild ( mountPoint ) ;
245+ } ) ;
246+
247+ function checkTabRemovingWithAnimation ( animation ) {
248+ it ( `should correctly set "active" after tabPane is removed with "animation=${ animation } "` , function ( ) {
249+ let instance = render (
250+ < TabbedArea activeKey = { 2 } animation = { animation } >
251+ < TabPane tab = "Tab 1" eventKey = { 1 } > Tab 1 content</ TabPane >
252+ < TabPane tab = "Tab 2" eventKey = { 2 } > Tab 2 content</ TabPane >
253+ </ TabbedArea >
254+ , mountPoint ) ;
255+
256+ let panes = ReactTestUtils . scryRenderedComponentsWithType ( instance , TabPane ) ;
257+
258+ assert . equal ( panes [ 0 ] . props . active , false ) ;
259+ assert . equal ( panes [ 1 ] . props . active , true ) ;
260+
261+ // second tab has been removed
262+ render (
263+ < TabbedArea activeKey = { 1 } animation = { animation } >
264+ < TabPane tab = "Tab 1" eventKey = { 1 } > Tab 1 content</ TabPane >
265+ </ TabbedArea >
266+ , mountPoint ) ;
267+
268+ assert . equal ( panes [ 0 ] . props . active , true ) ;
269+ } ) ;
270+ }
271+
272+ checkTabRemovingWithAnimation ( true ) ;
273+ checkTabRemovingWithAnimation ( false ) ;
274+ } ) ;
275+
233276 describe ( 'Web Accessibility' , function ( ) {
234277
235278 it ( 'Should generate ids from parent id' , function ( ) {
0 commit comments