@@ -5,11 +5,8 @@ import type { RenderedTreeExplorerNode } from '@/types/treeExplorerTypes'
55import type { WindowRange } from '../virtualListUtils'
66import {
77 applyWindow ,
8- calculateScrollPercentage ,
98 calculateSpacerHeights ,
10- createInitialWindowRange ,
11- shiftWindowBackward ,
12- shiftWindowForward
9+ createInitialWindowRange
1310} from '../virtualListUtils'
1411
1512describe ( 'virtualListUtils' , ( ) => {
@@ -30,58 +27,6 @@ describe('virtualListUtils', () => {
3027 } )
3128 } )
3229
33- describe ( 'shiftWindowForward' , ( ) => {
34- it ( 'shifts window forward by buffer size' , ( ) => {
35- const currentRange : WindowRange = { start : 0 , end : 60 }
36- const result = shiftWindowForward ( currentRange , 100 , 20 , 60 )
37- expect ( result ) . toEqual ( { start : 20 , end : 80 } )
38- } )
39-
40- it ( 'returns null when already at end' , ( ) => {
41- const currentRange : WindowRange = { start : 40 , end : 100 }
42- const result = shiftWindowForward ( currentRange , 100 , 20 , 60 )
43- expect ( result ) . toBeNull ( )
44- } )
45-
46- it ( 'caps end at totalChildren' , ( ) => {
47- const currentRange : WindowRange = { start : 30 , end : 90 }
48- const result = shiftWindowForward ( currentRange , 100 , 20 , 60 )
49- expect ( result ) . toEqual ( { start : 40 , end : 100 } )
50- } )
51-
52- it ( 'adjusts start to maintain window size when near end' , ( ) => {
53- const currentRange : WindowRange = { start : 20 , end : 80 }
54- const result = shiftWindowForward ( currentRange , 95 , 20 , 60 )
55- expect ( result ) . toEqual ( { start : 35 , end : 95 } )
56- } )
57- } )
58-
59- describe ( 'shiftWindowBackward' , ( ) => {
60- it ( 'shifts window backward by buffer size' , ( ) => {
61- const currentRange : WindowRange = { start : 40 , end : 100 }
62- const result = shiftWindowBackward ( currentRange , 100 , 20 , 60 )
63- expect ( result ) . toEqual ( { start : 20 , end : 80 } )
64- } )
65-
66- it ( 'returns null when already at start' , ( ) => {
67- const currentRange : WindowRange = { start : 0 , end : 60 }
68- const result = shiftWindowBackward ( currentRange , 100 , 20 , 60 )
69- expect ( result ) . toBeNull ( )
70- } )
71-
72- it ( 'caps start at 0' , ( ) => {
73- const currentRange : WindowRange = { start : 10 , end : 70 }
74- const result = shiftWindowBackward ( currentRange , 100 , 20 , 60 )
75- expect ( result ) . toEqual ( { start : 0 , end : 60 } )
76- } )
77-
78- it ( 'caps end at totalChildren when window would exceed' , ( ) => {
79- const currentRange : WindowRange = { start : 20 , end : 50 }
80- const result = shiftWindowBackward ( currentRange , 50 , 20 , 60 )
81- expect ( result ) . toEqual ( { start : 0 , end : 50 } )
82- } )
83- } )
84-
8530 describe ( 'calculateSpacerHeights' , ( ) => {
8631 it ( 'calculates correct spacer heights' , ( ) => {
8732 const range : WindowRange = { start : 20 , end : 80 }
@@ -119,35 +64,6 @@ describe('virtualListUtils', () => {
11964 } )
12065 } )
12166 } )
122-
123- describe ( 'calculateScrollPercentage' , ( ) => {
124- it ( 'calculates percentage correctly' , ( ) => {
125- const result = calculateScrollPercentage ( 500 , 2000 , 400 , 0 , 0 )
126- expect ( result ) . toBeCloseTo ( 0.45 )
127- } )
128-
129- it ( 'adjusts for top spacer height' , ( ) => {
130- const result = calculateScrollPercentage ( 600 , 2000 , 400 , 200 , 200 )
131- // realContentHeight = 2000 - 200 - 200 = 1600
132- // adjustedScrollTop = max(0, 600 - 200) = 400
133- // percentage = (400 + 400) / 1600 = 0.5
134- expect ( result ) . toBeCloseTo ( 0.5 )
135- } )
136-
137- it ( 'returns 1 when realContentHeight is 0' , ( ) => {
138- const result = calculateScrollPercentage ( 0 , 100 , 50 , 50 , 50 )
139- expect ( result ) . toBe ( 1 )
140- } )
141-
142- it ( 'handles scrollTop less than topSpacerHeight' , ( ) => {
143- const result = calculateScrollPercentage ( 100 , 2000 , 400 , 200 , 200 )
144- // adjustedScrollTop = max(0, 100 - 200) = 0
145- // realContentHeight = 1600
146- // percentage = (0 + 400) / 1600 = 0.25
147- expect ( result ) . toBeCloseTo ( 0.25 )
148- } )
149- } )
150-
15167 describe ( 'applyWindow' , ( ) => {
15268 const createMockNode = (
15369 key : string ,
0 commit comments