@@ -154,11 +154,11 @@ describe('Tab', () => {
154
154
} )
155
155
156
156
describe ( 'onTabChange' , ( ) => {
157
- it ( 'is called with (e, { ...props, activeIndex }) a menu item is clicked' , ( ) => {
157
+ it ( 'is called when a menu item is clicked' , ( ) => {
158
158
const activeIndex = 1
159
- const spy = sandbox . spy ( )
159
+ const onTabChange = sandbox . spy ( )
160
160
const event = { fake : 'event' }
161
- const props = { onTabChange : spy , panes }
161
+ const props = { onTabChange, panes }
162
162
163
163
mount ( < Tab { ...props } /> )
164
164
. find ( 'MenuItem' )
@@ -167,30 +167,29 @@ describe('Tab', () => {
167
167
168
168
// Since React will have generated a key the returned tab won't match
169
169
// exactly so match on the props instead.
170
- spy . should . have . been . calledOnce ( )
171
- spy . firstCall . args [ 0 ] . should . have . property ( 'fake' , 'event' )
172
- spy . firstCall . args [ 1 ] . should . have . property ( 'activeIndex' , 1 )
173
- spy . firstCall . args [ 1 ] . should . have . property ( 'onTabChange' , spy )
174
- spy . firstCall . args [ 1 ] . should . have . property ( 'panes' , panes )
170
+ onTabChange . should . have . been . calledOnce ( )
171
+ onTabChange . should . have . been . calledWithMatch ( event , props , 1 )
175
172
} )
176
173
it ( 'is called with the new proposed activeIndex, not the current' , ( ) => {
177
- const spy = sandbox . spy ( )
174
+ const onTabChange = sandbox . spy ( )
178
175
179
- const items = mount ( < Tab activeIndex = { - 1 } onTabChange = { spy } panes = { panes } /> ) . find ( 'MenuItem' )
176
+ const items = mount ( < Tab activeIndex = { - 1 } onTabChange = { onTabChange } panes = { panes } /> ) . find (
177
+ 'MenuItem' ,
178
+ )
180
179
181
- spy . should . have . callCount ( 0 )
180
+ onTabChange . should . have . callCount ( 0 )
182
181
183
182
items . at ( 0 ) . simulate ( 'click' )
184
- spy . should . have . callCount ( 1 )
185
- spy . lastCall . args [ 1 ] . should . have . property ( 'activeIndex' , 0 )
183
+ onTabChange . should . have . callCount ( 1 )
184
+ onTabChange . lastCall . args [ 2 ] . should . equal ( 0 )
186
185
187
186
items . at ( 1 ) . simulate ( 'click' )
188
- spy . should . have . callCount ( 2 )
189
- spy . lastCall . args [ 1 ] . should . have . property ( 'activeIndex' , 1 )
187
+ onTabChange . should . have . callCount ( 2 )
188
+ onTabChange . lastCall . args [ 2 ] . should . equal ( 1 )
190
189
191
190
items . at ( 2 ) . simulate ( 'click' )
192
- spy . should . have . callCount ( 3 )
193
- spy . lastCall . args [ 1 ] . should . have . property ( 'activeIndex' , 2 )
191
+ onTabChange . should . have . callCount ( 3 )
192
+ onTabChange . lastCall . args [ 2 ] . should . equal ( 2 )
194
193
} )
195
194
} )
196
195
0 commit comments