@@ -92,6 +92,50 @@ describe('applyLanes', () => {
9292 ] ) ;
9393 } ) ;
9494
95+ it ( 'should work with nested string keys for start and end' , ( ) => {
96+ const data = [
97+ { name : 'Task 1' , duration : { start : new Date ( '2023-01-01' ) , end : new Date ( '2023-01-02' ) } } ,
98+ { name : 'Task 2' , duration : { start : new Date ( '2023-01-03' ) , end : new Date ( '2023-01-04' ) } } ,
99+ ] ;
100+
101+ const result = applyLanes ( data , { start : 'duration.start' , end : 'duration.end' } ) ;
102+
103+ expect ( result ) . toEqual ( [
104+ {
105+ name : 'Task 1' ,
106+ duration : { start : new Date ( '2023-01-01' ) , end : new Date ( '2023-01-02' ) } ,
107+ lane : 0 ,
108+ } ,
109+ {
110+ name : 'Task 2' ,
111+ duration : { start : new Date ( '2023-01-03' ) , end : new Date ( '2023-01-04' ) } ,
112+ lane : 0 ,
113+ } ,
114+ ] ) ;
115+ } ) ;
116+
117+ it ( 'should work with function accessors for start and end' , ( ) => {
118+ const data = [
119+ { name : 'Task 1' , duration : { start : new Date ( '2023-01-01' ) , end : new Date ( '2023-01-02' ) } } ,
120+ { name : 'Task 2' , duration : { start : new Date ( '2023-01-03' ) , end : new Date ( '2023-01-04' ) } } ,
121+ ] ;
122+
123+ const result = applyLanes ( data , { start : ( d ) => d . duration . start , end : ( d ) => d . duration . end } ) ;
124+
125+ expect ( result ) . toEqual ( [
126+ {
127+ name : 'Task 1' ,
128+ duration : { start : new Date ( '2023-01-01' ) , end : new Date ( '2023-01-02' ) } ,
129+ lane : 0 ,
130+ } ,
131+ {
132+ name : 'Task 2' ,
133+ duration : { start : new Date ( '2023-01-03' ) , end : new Date ( '2023-01-04' ) } ,
134+ lane : 0 ,
135+ } ,
136+ ] ) ;
137+ } ) ;
138+
95139 it ( 'should handle empty array' , ( ) => {
96140 const data : any [ ] = [ ] ;
97141 const result = applyLanes ( data ) ;
0 commit comments