@@ -166,8 +166,11 @@ describe('<Foldable.Body />', () => {
166166 } )
167167 expect ( $ . html ( ) ) . toMatch ( / s t y l e = " d i s p l a y : b l o c k ; o v e r f l o w : h i d d e n ; h e i g h t : 0 p x ; " / )
168168
169+ jest . runTimersToTime ( 1 )
170+ expect ( $ . html ( ) ) . toMatch ( / s t y l e = " d i s p l a y : b l o c k ; o v e r f l o w : h i d d e n ; h e i g h t : 1 0 0 p x ; " / )
171+
169172 jest . runAllTimers ( )
170- expect ( $ . html ( ) ) . toMatch ( / s t y l e = " d i s p l a y : b l o c k ; o v e r f l o w : v i s i b l e ; h e i g h t : 1 0 0 p x ; " / )
173+ expect ( $ . html ( ) ) . toMatch ( / s t y l e = " d i s p l a y : b l o c k ; o v e r f l o w : v i s i b l e ; h e i g h t : a u t o ; " / )
171174 } )
172175
173176 it ( 'can transition to closed from initial open position' , ( ) => {
@@ -194,13 +197,16 @@ describe('<Foldable.Body />', () => {
194197 ...defaultContext ,
195198 isFoldableOpen : false
196199 } )
200+ expect ( $ . html ( ) ) . toMatch ( / s t y l e = " h e i g h t : 1 0 0 p x ; " / )
201+
202+ jest . runTimersToTime ( 1 )
197203 expect ( $ . html ( ) ) . toMatch ( / s t y l e = " h e i g h t : 0 p x ; o v e r f l o w : h i d d e n ; " / )
198204
199205 jest . runAllTimers ( )
200206 expect ( $ . html ( ) ) . toMatch ( / s t y l e = " h e i g h t : 0 p x ; o v e r f l o w : h i d d e n ; d i s p l a y : n o n e ; " / )
201207 } )
202208
203- it ( 'can take a set transiion duration and handles opening before close duration has ended' , ( ) => {
209+ it ( 'can take a set transition duration and handles opening before close duration has ended' , ( ) => {
204210 jest . useFakeTimers ( )
205211 getHeight . mockImplementation ( ( ) => '100' )
206212
@@ -224,6 +230,9 @@ describe('<Foldable.Body />', () => {
224230 ...defaultContext ,
225231 isFoldableOpen : false
226232 } )
233+ expect ( $ . html ( ) ) . toMatch ( / s t y l e = " h e i g h t : 1 0 0 p x ; " / )
234+
235+ jest . runTimersToTime ( 1 )
227236 expect ( $ . html ( ) ) . toMatch ( / s t y l e = " h e i g h t : 0 p x ; o v e r f l o w : h i d d e n ; " / )
228237
229238 jest . runTimersToTime ( 500 )
@@ -233,6 +242,62 @@ describe('<Foldable.Body />', () => {
233242 } )
234243
235244 expect ( $ . html ( ) ) . toMatch ( / s t y l e = " h e i g h t : 1 0 0 p x ; o v e r f l o w : h i d d e n ; d i s p l a y : b l o c k ; " / )
245+
246+ jest . runAllTimers ( )
247+ expect ( $ . html ( ) ) . toMatch ( / s t y l e = " h e i g h t : a u t o ; o v e r f l o w : v i s i b l e ; d i s p l a y : b l o c k ; " / )
248+ } )
249+
250+ it ( 'removes styles related to transition if transition prop is removed' , ( ) => {
251+ jest . useFakeTimers ( )
252+ getHeight . mockImplementation ( ( ) => '100' )
253+
254+ const context = {
255+ ...defaultContext ,
256+ isFoldableOpen : true
257+ }
258+
259+ const $ = mount (
260+ < Foldable . Body transition >
261+ _
262+ </ Foldable . Body >
263+ , { context }
264+ )
265+
266+ expect ( $ . html ( ) ) . toMatch ( / s t y l e = " h e i g h t : a u t o ; " / )
267+
268+ jest . runAllTimers ( )
269+ expect ( $ . html ( ) ) . toMatch ( / s t y l e = " h e i g h t : 1 0 0 p x ; " / )
270+
271+ $ . setProps ( {
272+ transition : false
273+ } )
274+
275+ expect ( $ . html ( ) ) . toMatch ( / s t y l e = " " / )
276+ } )
277+
278+ it ( 'sets initial transition styles if transition prop is added' , ( ) => {
279+ jest . useFakeTimers ( )
280+ getHeight . mockImplementation ( ( ) => '100' )
281+
282+ const context = {
283+ ...defaultContext ,
284+ isFoldableOpen : true
285+ }
286+
287+ const $ = mount (
288+ < Foldable . Body >
289+ _
290+ </ Foldable . Body >
291+ , { context }
292+ )
293+
294+ expect ( $ . html ( ) ) . not . toMatch ( / s t y l e = " h e i g h t / )
295+
296+ $ . setProps ( {
297+ transition : true
298+ } )
299+
300+ expect ( $ . html ( ) ) . toMatch ( / s t y l e = " h e i g h t : a u t o ; / )
236301 } )
237302 } )
238303} )
0 commit comments