@@ -111,4 +111,77 @@ describe('child/size/auto branches', () => {
111111 } )
112112 expect ( res ) . toBeGreaterThanOrEqual ( 100 )
113113 } )
114+
115+ it ( 'hasTags branch uses taggedElement' , async ( ) => {
116+ state . firstRun = false
117+ state . hasTags = true
118+ const res = auto ( {
119+ ...base ,
120+ taggedElement : ( ) => 250 ,
121+ } )
122+ expect ( res ) . toBe ( 250 )
123+ } )
124+
125+ it ( 'html size decreased when no overflow' , async ( ) => {
126+ // First call to establish previous size (must trigger getBoundingClientRect to set prevBoundingSize)
127+ state . firstRun = true
128+ state . hasOverflow = false
129+ auto ( {
130+ ...base ,
131+ boundingClientRect : ( ) => 150 ,
132+ documentElementScroll : ( ) => 100 ,
133+ } )
134+
135+ // Second call with decreased bounding size, but INCREASED scroll size
136+ // This ensures we don't match the earlier case (line 79-81) which requires scrollSize <= prevScrollSize
137+ state . firstRun = false
138+ state . hasOverflow = false
139+ const res = auto ( {
140+ ...base ,
141+ boundingClientRect : ( ) => 120 , // decreased from 150
142+ documentElementScroll : ( ) => 110 , // increased from 100
143+ } )
144+ expect ( res ) . toBe ( 120 )
145+ } )
146+
147+ it ( 'scrollSize equals floor of boundingSize' , async ( ) => {
148+ state . firstRun = false
149+ const res = auto ( {
150+ ...base ,
151+ boundingClientRect : ( ) => 100.7 ,
152+ documentElementScroll : ( ) => 100 , // equals floor(100.7)
153+ } )
154+ expect ( res ) . toBe ( 100.7 )
155+ } )
156+
157+ it ( 'scrollSize equals ceil of boundingSize' , async ( ) => {
158+ state . firstRun = false
159+ const res = auto ( {
160+ ...base ,
161+ boundingClientRect : ( ) => 100.3 ,
162+ documentElementScroll : ( ) => 101 , // equals ceil(100.3)
163+ } )
164+ expect ( res ) . toBe ( 100.3 )
165+ } )
166+
167+ it ( 'boundingSize greater than scrollSize' , async ( ) => {
168+ state . firstRun = false
169+ const res = auto ( {
170+ ...base ,
171+ boundingClientRect : ( ) => 180 ,
172+ documentElementScroll : ( ) => 160 ,
173+ } )
174+ expect ( res ) . toBe ( 180 )
175+ } )
176+
177+ it ( 'getOffset adds to calculated size' , async ( ) => {
178+ state . firstRun = false
179+ const res = auto ( {
180+ ...base ,
181+ boundingClientRect : ( ) => 100 ,
182+ documentElementScroll : ( ) => 100 ,
183+ getOffset : ( ) => 15 ,
184+ } )
185+ expect ( res ) . toBe ( 115 ) // 100 + 15 offset
186+ } )
114187} )
0 commit comments