@@ -6,7 +6,7 @@ describe('useCollapse', () => {
66 it ( 'should return expected methods and properties' , ( ) => {
77 const collapsed = ref ( false ) ;
88 const sizePercentage = ref ( 50 ) ;
9- const options = { transitionDuration : 300 } ;
9+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
1010
1111 const result = useCollapse ( collapsed , sizePercentage , options ) ;
1212
@@ -26,7 +26,7 @@ describe('useCollapse', () => {
2626 it ( 'should set collapsed to true' , ( ) => {
2727 const collapsed = ref ( false ) ;
2828 const sizePercentage = ref ( 50 ) ;
29- const options = { transitionDuration : 300 } ;
29+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
3030
3131 const { collapse } = useCollapse ( collapsed , sizePercentage , options ) ;
3232
@@ -40,7 +40,7 @@ describe('useCollapse', () => {
4040 it ( 'should set collapsed to false' , ( ) => {
4141 const collapsed = ref ( true ) ;
4242 const sizePercentage = ref ( 0 ) ;
43- const options = { transitionDuration : 300 } ;
43+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
4444
4545 const { expand } = useCollapse ( collapsed , sizePercentage , options ) ;
4646
@@ -54,7 +54,7 @@ describe('useCollapse', () => {
5454 it ( 'should set collapsed to the provided value' , ( ) => {
5555 const collapsed = ref ( false ) ;
5656 const sizePercentage = ref ( 50 ) ;
57- const options = { transitionDuration : 300 } ;
57+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
5858
5959 const { toggle } = useCollapse ( collapsed , sizePercentage , options ) ;
6060
@@ -67,10 +67,10 @@ describe('useCollapse', () => {
6767 } ) ;
6868
6969 describe ( 'collapsed watcher behavior' , ( ) => {
70- it ( 'should store size and set to 0 when collapsing' , async ( ) => {
70+ it ( 'should store size and set to collapsedSize when collapsing' , async ( ) => {
7171 const collapsed = ref ( false ) ;
7272 const sizePercentage = ref ( 75 ) ;
73- const options = { transitionDuration : 300 } ;
73+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
7474
7575 const { collapseTransitionState } = useCollapse ( collapsed , sizePercentage , options ) ;
7676
@@ -84,7 +84,7 @@ describe('useCollapse', () => {
8484 it ( 'should restore size when expanding' , async ( ) => {
8585 const collapsed = ref ( false ) ;
8686 const sizePercentage = ref ( 60 ) ;
87- const options = { transitionDuration : 300 } ;
87+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
8888
8989 const { collapseTransitionState } = useCollapse ( collapsed , sizePercentage , options ) ;
9090
@@ -104,7 +104,7 @@ describe('useCollapse', () => {
104104 it ( 'should preserve original size through multiple collapse/expand cycles' , async ( ) => {
105105 const collapsed = ref ( false ) ;
106106 const sizePercentage = ref ( 42 ) ;
107- const options = { transitionDuration : 300 } ;
107+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
108108
109109 useCollapse ( collapsed , sizePercentage , options ) ;
110110
@@ -130,7 +130,7 @@ describe('useCollapse', () => {
130130 it ( 'should handle size changes between collapse cycles' , async ( ) => {
131131 const collapsed = ref ( false ) ;
132132 const sizePercentage = ref ( 30 ) ;
133- const options = { transitionDuration : 300 } ;
133+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
134134
135135 useCollapse ( collapsed , sizePercentage , options ) ;
136136
@@ -163,7 +163,7 @@ describe('useCollapse', () => {
163163 it ( 'should start with null transition state' , ( ) => {
164164 const collapsed = ref ( false ) ;
165165 const sizePercentage = ref ( 50 ) ;
166- const options = { transitionDuration : 300 } ;
166+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
167167
168168 const { collapseTransitionState } = useCollapse ( collapsed , sizePercentage , options ) ;
169169
@@ -173,7 +173,7 @@ describe('useCollapse', () => {
173173 it ( 'should set collapsing state when collapsed becomes true' , async ( ) => {
174174 const collapsed = ref ( false ) ;
175175 const sizePercentage = ref ( 50 ) ;
176- const options = { transitionDuration : 300 } ;
176+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
177177
178178 const { collapseTransitionState } = useCollapse ( collapsed , sizePercentage , options ) ;
179179
@@ -186,7 +186,7 @@ describe('useCollapse', () => {
186186 it ( 'should set expanding state when collapsed becomes false' , async ( ) => {
187187 const collapsed = ref ( true ) ;
188188 const sizePercentage = ref ( 0 ) ;
189- const options = { transitionDuration : 300 } ;
189+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
190190
191191 const { collapseTransitionState } = useCollapse ( collapsed , sizePercentage , options ) ;
192192
@@ -201,7 +201,7 @@ describe('useCollapse', () => {
201201 it ( 'should return CSS transition duration' , ( ) => {
202202 const collapsed = ref ( false ) ;
203203 const sizePercentage = ref ( 50 ) ;
204- const options = { transitionDuration : 500 } ;
204+ const options = { transitionDuration : 500 , collapsedSize : 0 } ;
205205
206206 const { transitionDurationCss } = useCollapse ( collapsed , sizePercentage , options ) ;
207207
@@ -212,7 +212,7 @@ describe('useCollapse', () => {
212212 const collapsed = ref ( false ) ;
213213 const sizePercentage = ref ( 50 ) ;
214214 const transitionDuration = ref ( 300 ) ;
215- const options = { transitionDuration } ;
215+ const options = { transitionDuration, collapsedSize : 0 } ;
216216
217217 const { transitionDurationCss } = useCollapse ( collapsed , sizePercentage , options ) ;
218218
@@ -227,7 +227,7 @@ describe('useCollapse', () => {
227227 it ( 'should handle rapid collapse/expand operations' , async ( ) => {
228228 const collapsed = ref ( false ) ;
229229 const sizePercentage = ref ( 65 ) ;
230- const options = { transitionDuration : 300 } ;
230+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
231231
232232 const { collapseTransitionState } = useCollapse ( collapsed , sizePercentage , options ) ;
233233
@@ -247,7 +247,7 @@ describe('useCollapse', () => {
247247 it ( 'should work with methods triggering state changes' , async ( ) => {
248248 const collapsed = ref ( false ) ;
249249 const sizePercentage = ref ( 45 ) ;
250- const options = { transitionDuration : 300 } ;
250+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
251251
252252 const { collapse, expand, toggle, collapseTransitionState } = useCollapse ( collapsed , sizePercentage , options ) ;
253253
@@ -276,7 +276,7 @@ describe('useCollapse', () => {
276276 it ( 'should work with zero initial size' , async ( ) => {
277277 const collapsed = ref ( false ) ;
278278 const sizePercentage = ref ( 0 ) ;
279- const options = { transitionDuration : 300 } ;
279+ const options = { transitionDuration : 300 , collapsedSize : 0 } ;
280280
281281 useCollapse ( collapsed , sizePercentage , options ) ;
282282
@@ -290,5 +290,51 @@ describe('useCollapse', () => {
290290 await nextTick ( ) ;
291291 expect ( sizePercentage . value ) . toBe ( 0 ) ;
292292 } ) ;
293+
294+ it ( 'should use custom collapsedSize value' , async ( ) => {
295+ const collapsed = ref ( false ) ;
296+ const sizePercentage = ref ( 60 ) ;
297+ const options = { transitionDuration : 300 , collapsedSize : 10 } ;
298+
299+ const { collapseTransitionState } = useCollapse ( collapsed , sizePercentage , options ) ;
300+
301+ // Collapse to custom size
302+ collapsed . value = true ;
303+ await nextTick ( ) ;
304+ expect ( sizePercentage . value ) . toBe ( 10 ) ;
305+ expect ( collapseTransitionState . value ) . toBe ( 'collapsing' ) ;
306+
307+ // Expand should restore original size
308+ collapsed . value = false ;
309+ await nextTick ( ) ;
310+ expect ( sizePercentage . value ) . toBe ( 60 ) ;
311+ expect ( collapseTransitionState . value ) . toBe ( 'expanding' ) ;
312+ } ) ;
313+
314+ it ( 'should support reactive collapsedSize value' , async ( ) => {
315+ const collapsed = ref ( false ) ;
316+ const sizePercentage = ref ( 70 ) ;
317+ const collapsedSize = ref ( 5 ) ;
318+ const options = { transitionDuration : 300 , collapsedSize } ;
319+
320+ useCollapse ( collapsed , sizePercentage , options ) ;
321+
322+ // Collapse with initial collapsedSize
323+ collapsed . value = true ;
324+ await nextTick ( ) ;
325+ expect ( sizePercentage . value ) . toBe ( 5 ) ;
326+
327+ // Change collapsedSize while collapsed
328+ collapsedSize . value = 15 ;
329+
330+ // Expand and collapse again with new collapsedSize
331+ collapsed . value = false ;
332+ await nextTick ( ) ;
333+ expect ( sizePercentage . value ) . toBe ( 70 ) ;
334+
335+ collapsed . value = true ;
336+ await nextTick ( ) ;
337+ expect ( sizePercentage . value ) . toBe ( 15 ) ;
338+ } ) ;
293339 } ) ;
294340} ) ;
0 commit comments