11import React from 'react' ;
2- import { mount , ReactWrapper } from 'enzyme' ;
2+ import type { ReactWrapper } from 'enzyme' ;
3+ import { mount } from 'enzyme' ;
34import KeyCode from 'rc-util/lib/KeyCode' ;
45import Tabs , { TabPane } from '../src' ;
5- import { TabsProps } from '../src/Tabs' ;
6+ import type { TabsProps } from '../src/Tabs' ;
67
78describe ( 'Tabs.Basic' , ( ) => {
89 function getTabs ( props : TabsProps = null ) {
@@ -54,29 +55,18 @@ describe('Tabs.Basic', () => {
5455 const list : { name : string ; trigger : ( wrapper : ReactWrapper ) => void } [ ] = [
5556 {
5657 name : 'outer div' ,
57- trigger : wrapper =>
58- wrapper
59- . find ( '.rc-tabs-tab' )
60- . at ( 2 )
61- . simulate ( 'click' ) ,
58+ trigger : ( wrapper ) => wrapper . find ( '.rc-tabs-tab' ) . at ( 2 ) . simulate ( 'click' ) ,
6259 } ,
6360 {
6461 name : 'inner button' ,
65- trigger : wrapper =>
66- wrapper
67- . find ( '.rc-tabs-tab .rc-tabs-tab-btn' )
68- . at ( 2 )
69- . simulate ( 'click' ) ,
62+ trigger : ( wrapper ) => wrapper . find ( '.rc-tabs-tab .rc-tabs-tab-btn' ) . at ( 2 ) . simulate ( 'click' ) ,
7063 } ,
7164 {
7265 name : 'inner button key down' ,
73- trigger : wrapper =>
74- wrapper
75- . find ( '.rc-tabs-tab .rc-tabs-tab-btn' )
76- . at ( 2 )
77- . simulate ( 'keydown' , {
78- which : KeyCode . SPACE ,
79- } ) ,
66+ trigger : ( wrapper ) =>
67+ wrapper . find ( '.rc-tabs-tab .rc-tabs-tab-btn' ) . at ( 2 ) . simulate ( 'keydown' , {
68+ which : KeyCode . SPACE ,
69+ } ) ,
8070 } ,
8171 ] ;
8272
@@ -123,28 +113,18 @@ describe('Tabs.Basic', () => {
123113
124114 it ( 'tabBarGutter should work' , ( ) => {
125115 const topTabs = mount ( getTabs ( { tabBarGutter : 23 } ) ) ;
126- expect (
127- topTabs
128- . find ( '.rc-tabs-tab' )
129- . first ( )
130- . props ( ) . style . marginRight ,
131- ) . toEqual ( 23 ) ;
116+ expect ( topTabs . find ( '.rc-tabs-tab' ) . first ( ) . props ( ) . style . marginLeft ) . toEqual ( 23 ) ;
132117
133118 const rightTabs = mount ( getTabs ( { tabBarGutter : 33 , tabPosition : 'right' } ) ) ;
134- expect (
135- rightTabs
136- . find ( '.rc-tabs-tab' )
137- . first ( )
138- . props ( ) . style . marginBottom ,
139- ) . toEqual ( 33 ) ;
119+ expect ( rightTabs . find ( '.rc-tabs-tab' ) . first ( ) . props ( ) . style . marginTop ) . toEqual ( 33 ) ;
140120 } ) ;
141121
142122 describe ( 'renderTabBar' , ( ) => {
143123 it ( 'works' , ( ) => {
144124 const renderTabBar = jest . fn ( ( props , Component ) => {
145125 return (
146126 < div className = "my-wrapper" >
147- < Component { ...props } > { node => < span className = "my-node" > { node } </ span > } </ Component >
127+ < Component { ...props } > { ( node ) => < span className = "my-node" > { node } </ span > } </ Component >
148128 </ div >
149129 ) ;
150130 } ) ;
@@ -154,10 +134,10 @@ describe('Tabs.Basic', () => {
154134 expect ( renderTabBar ) . toHaveBeenCalled ( ) ;
155135 } ) ;
156136 it ( 'has panes property in props' , ( ) => {
157- const renderTabBar = props => {
137+ const renderTabBar = ( props ) => {
158138 return (
159139 < div >
160- { props . panes . map ( pane => (
140+ { props . panes . map ( ( pane ) => (
161141 < span key = { pane . key } data-key = { pane . key } >
162142 tab
163143 </ span >
@@ -182,18 +162,8 @@ describe('Tabs.Basic', () => {
182162 ) ;
183163
184164 function matchText ( light : string , bamboo : string ) {
185- expect (
186- wrapper
187- . find ( '.rc-tabs-tabpane' )
188- . first ( )
189- . text ( ) ,
190- ) . toEqual ( light ) ;
191- expect (
192- wrapper
193- . find ( '.rc-tabs-tabpane' )
194- . last ( )
195- . text ( ) ,
196- ) . toEqual ( bamboo ) ;
165+ expect ( wrapper . find ( '.rc-tabs-tabpane' ) . first ( ) . text ( ) ) . toEqual ( light ) ;
166+ expect ( wrapper . find ( '.rc-tabs-tabpane' ) . last ( ) . text ( ) ) . toEqual ( bamboo ) ;
197167 }
198168
199169 matchText ( 'Light' , '' ) ;
@@ -212,10 +182,7 @@ describe('Tabs.Basic', () => {
212182 it ( 'add' , ( ) => {
213183 const onEdit = jest . fn ( ) ;
214184 const wrapper = mount ( getTabs ( { editable : { onEdit } } ) ) ;
215- wrapper
216- . find ( '.rc-tabs-nav-add' )
217- . first ( )
218- . simulate ( 'click' ) ;
185+ wrapper . find ( '.rc-tabs-nav-add' ) . first ( ) . simulate ( 'click' ) ;
219186 expect ( onEdit ) . toHaveBeenCalledWith ( 'add' , {
220187 key : undefined ,
221188 event : expect . anything ( ) ,
@@ -225,7 +192,7 @@ describe('Tabs.Basic', () => {
225192 const list : { name : string ; trigger : ( node : ReactWrapper ) => void } [ ] = [
226193 {
227194 name : 'click' ,
228- trigger : node => {
195+ trigger : ( node ) => {
229196 node . simulate ( 'click' ) ;
230197 } ,
231198 } ,
@@ -275,19 +242,9 @@ describe('Tabs.Basic', () => {
275242 const wrapper = mount (
276243 getTabs ( { tabBarExtraContent : { left : 'Left Bamboo' , right : 'Right Bamboo' } } ) ,
277244 ) ;
278- expect (
279- wrapper
280- . find ( '.rc-tabs-extra-content' )
281- . first ( )
282- . text ( ) ,
283- ) . toEqual ( 'Left Bamboo' ) ;
284-
285- expect (
286- wrapper
287- . find ( '.rc-tabs-extra-content' )
288- . at ( 1 )
289- . text ( ) ,
290- ) . toEqual ( 'Right Bamboo' ) ;
245+ expect ( wrapper . find ( '.rc-tabs-extra-content' ) . first ( ) . text ( ) ) . toEqual ( 'Left Bamboo' ) ;
246+
247+ expect ( wrapper . find ( '.rc-tabs-extra-content' ) . at ( 1 ) . text ( ) ) . toEqual ( 'Right Bamboo' ) ;
291248 } ) ;
292249
293250 describe ( 'animated' , ( ) => {
@@ -318,10 +275,7 @@ describe('Tabs.Basic', () => {
318275
319276 it ( 'focus to scroll' , ( ) => {
320277 const wrapper = mount ( getTabs ( ) ) ;
321- wrapper
322- . find ( '.rc-tabs-tab' )
323- . first ( )
324- . simulate ( 'focus' ) ;
278+ wrapper . find ( '.rc-tabs-tab' ) . first ( ) . simulate ( 'focus' ) ;
325279
326280 wrapper . unmount ( ) ;
327281 } ) ;
0 commit comments