@@ -77,6 +77,29 @@ describe('Accordion', () => {
7777 wrapper
7878 . should . have . state ( 'activeIndex' , - 1 )
7979 } )
80+ it ( 'sets the correct pair of title/content active' , ( ) => {
81+ const wrapper = shallow (
82+ < Accordion >
83+ < Accordion . Title />
84+ < Accordion . Content />
85+ < Accordion . Title />
86+ < Accordion . Content />
87+ < Accordion . Title />
88+ < Accordion . Content />
89+ </ Accordion >
90+ )
91+ wrapper . setProps ( { activeIndex : 0 } )
92+ wrapper . childAt ( 0 ) . should . have . prop ( 'active' , true )
93+ wrapper . childAt ( 1 ) . should . have . prop ( 'active' , true )
94+
95+ wrapper . setProps ( { activeIndex : 1 } )
96+ wrapper . childAt ( 2 ) . should . have . prop ( 'active' , true )
97+ wrapper . childAt ( 3 ) . should . have . prop ( 'active' , true )
98+
99+ wrapper . setProps ( { activeIndex : 2 } )
100+ wrapper . childAt ( 4 ) . should . have . prop ( 'active' , true )
101+ wrapper . childAt ( 5 ) . should . have . prop ( 'active' , true )
102+ } )
80103 } )
81104
82105 describe ( 'defaultActiveIndex' , ( ) => {
@@ -89,6 +112,7 @@ describe('Accordion', () => {
89112 describe ( 'onTitleClick' , ( ) => {
90113 it ( 'is called with (event, index)' , ( ) => {
91114 const spy = sandbox . spy ( )
115+ const event = { foo : 'bar' }
92116 const titles = mount (
93117 < Accordion onTitleClick = { spy } >
94118 < Accordion . Title />
@@ -97,11 +121,11 @@ describe('Accordion', () => {
97121 )
98122 . find ( 'AccordionTitle' )
99123
100- titles . at ( 0 ) . simulate ( 'click' )
101- spy . should . have . been . calledWithMatch ( { } , 0 )
124+ titles . at ( 0 ) . simulate ( 'click' , event )
125+ spy . should . have . been . calledWithMatch ( event , 0 )
102126
103- titles . at ( 1 ) . simulate ( 'click' )
104- spy . should . have . been . calledWithMatch ( { } , 1 )
127+ titles . at ( 1 ) . simulate ( 'click' , event )
128+ spy . should . have . been . calledWithMatch ( event , 1 )
105129 } )
106130 } )
107131
@@ -184,6 +208,7 @@ describe('Accordion', () => {
184208
185209 it ( 'is called with (event, index) on AccordionTitle click' , ( ) => {
186210 const spy = sandbox . spy ( )
211+ const event = { foo : 'bar' }
187212 const panels = [ {
188213 onClick : spy ,
189214 title : 'First panel' ,
@@ -192,15 +217,22 @@ describe('Accordion', () => {
192217 onClick : spy ,
193218 title : 'Second panel' ,
194219 content : 'second panel content' ,
220+ } , {
221+ onClick : spy ,
222+ title : 'Third panel' ,
223+ content : 'third panel content' ,
195224 } ]
196225 const titles = mount ( < Accordion panels = { panels } /> )
197226 . find ( 'AccordionTitle' )
198227
199- titles . at ( 0 ) . simulate ( 'click' )
200- spy . should . have . been . calledWithMatch ( { } , 0 )
228+ titles . at ( 0 ) . simulate ( 'click' , event )
229+ spy . should . have . been . calledWithMatch ( event , 0 )
230+
231+ titles . at ( 1 ) . simulate ( 'click' , event )
232+ spy . should . have . been . calledWithMatch ( event , 1 )
201233
202- titles . at ( 1 ) . simulate ( 'click' )
203- spy . should . have . been . calledWithMatch ( { } , 1 )
234+ titles . at ( 2 ) . simulate ( 'click' , event )
235+ spy . should . have . been . calledWithMatch ( event , 2 )
204236 } )
205237 } )
206238 } )
0 commit comments